在phpMyAdmin的SQL窗口中显示了一个分隔符;查询之间。它运行我在其中的所有查询只显示最后一个的结果。如何将结果合并到一个?
SELECT field1, field2, field3, field4, field5, field6
FROM table WHERE field2 = "AA" AND field3 LIKE '%BBB%';
SELECT field1, field2, field3, field4, field5, field6
FROM table WHERE field2 = "AA" AND field3 LIKE '%CCC%';
答案 0 :(得分:1)
UNION
怎么样?
SELECT field1, field2, field3, field4, field5, field6
FROM table WHERE field2 = "AA" AND field3 LIKE '%BBB%'
UNION
SELECT field1, field2, field3, field4, field5, field6
FROM table WHERE field2 = "AA" AND field3 LIKE '%CCC%';
<强>更新强>
简化查询:
SELECT field1, field2, field3, field4, field5, field6
FROM table WHERE field2 = "AA" AND (field3 LIKE '%BBB%' OR field3 LIKE '%CCC%')