0
where meetingID = [[WHERE IT MATCHES]] (select meetingID from meeting where categoryID = '1')

我不太确定在这里放什么来将这两者结合在一起?

4

2 回答 2

0

如果一个类别可以有多个,meetingID更好地使用它不会生成和错误,IN=

SELECT ...
FROM ....
where meetingID IN (select meetingID 
                    from meeting 
                     where categoryID = '1')

另一种方式是JOIN他们,例如。

SELECT DISTINCT a.*
FROM   tableName a
       INNER JOIN meeting b
           ON a.meetingID = b.meetingID 
WHERE  b.categoryID  = '1'
于 2013-01-15T13:57:48.583 回答
0

使用JOIN将提高性能。

SELECT ... 
FROM tablea a 
INNER JOIN meeting m ON a.meetingID = m.meetingID AND m.categoryID = '1'

或者

SELECT ... 
FROM tablea a 
INNER JOIN (SELECT meetingID 
            FROM meeting 
            WHERE categoryID = '1'
          ) b ON a.meetingID = b.meetingID;

检查此链接MySQL Optimizing Subqueries

于 2013-01-15T14:01:51.160 回答