我试图列出来自加利福尼亚州,洛杉矶的男性或女性人士,但我不希望所有来自加利福尼亚的男性和女性都被列入名单。
SELECT * FROM people
WHERE state='california'
AND city='los_angeles'
AND gender='male' OR gender='female'
我也尝试过:
SELECT * FROM people
WHERE city='los_angeles'
AND gender='male' OR gender='female'
答案 0 :(得分:3)
更紧凑:
$sql = mysql_query("SELECT * FROM people WHERE state='california'
AND city='los_angeles' AND gender in ('male','female')");
答案 1 :(得分:2)