Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
mysql查询2个带有count的表_Mysql_Sql - Fatal编程技术网

mysql查询2个带有count的表

mysql查询2个带有count的表,mysql,sql,Mysql,Sql,我有两张桌子。一个叫做艺术家。以下是表格结构: artistID lastname firstname nationality dateofbirth datedcease 另一个表称为work workId title copy medium description artist ID 什么是SQL查询以列出数据库中记录了多个副本的任何艺术作品(包括创作该作品的艺术家)的详细信息?尝试以下操作: SELECT w.copy, w.title, w.description, w.med

我有两张桌子。一个叫做艺术家。以下是表格结构:

artistID lastname firstname nationality dateofbirth datedcease
另一个表称为
work

workId title copy medium description artist ID
什么是SQL查询以列出数据库中记录了多个副本的任何艺术作品(包括创作该作品的艺术家)的详细信息?

尝试以下操作:

SELECT 
  w.copy, w.title, w.description, w.medium, 
  a.firstname + ' ' + a.lastname AS 'Artist created the work'
FROM artists a
INNER JOIN
(
    SELECT * 
    FROM work 
    WHERE artistID IN
    ( 
        SELECT artistID
        FROM work 
        GROUP BY artistID
        HAVING COUNT(*) > 1 
    )
) w ON a.artistID = w.artistID
这里有一个

试试这个:

SELECT 
  w.copy, w.title, w.description, w.medium, 
  a.firstname + ' ' + a.lastname AS 'Artist created the work'
FROM artists a
INNER JOIN
(
    SELECT * 
    FROM work 
    WHERE artistID IN
    ( 
        SELECT artistID
        FROM work 
        GROUP BY artistID
        HAVING COUNT(*) > 1 
    )
) w ON a.artistID = w.artistID
这是一个