使用如下查询,您可以获取 id 的颜色为蓝色、紫色、绿色、白色和黑色的行。
SELECT t1.id, col
FROM extra as e INNER JOIN your_table as t1 USING ( id )
CROSS JOIN your_table as t2 USING ( id )
CROSS JOIN your_table as t3 USING ( id )
CROSS JOIN your_table as t4 USING ( id )
CROSS JOIN your_table as t5 USING ( id )
WHERE t1.color = 'blue' and t2.color = 'purple' and t3.color= 'green' and t4.color= 'white' and t5.color= 'black'
如果您尝试使用 != 或 NOT IN,它似乎不起作用。我将如何编写查询以使颜色包含蓝色、紫色、绿色、白色,但不包含黑色?