谁能告诉我写这个查询的正确方法?

时间:2013-10-16 20:06:44

标签: mysql

我正试图从图库字段值为1和3的故事中显示记录。 任何人都可以帮我解决这个问题吗?

$q = mysqli_query($link, "SELECT * FROM gallery WHERE gallery = 1 AND WHERE gallery = 3");

1 个答案:

答案 0 :(得分:8)

我想你写道:

$q = mysqli_query($link, "SELECT * FROM gallery WHERE gallery = 1 OR gallery = 3");

因为gallery = 1 AND gallery = 3总是FALSE!

或者你可以写:

$q = mysqli_query($link, "SELECT * FROM gallery WHERE gallery IN (1, 3)");

IN子句与OR链相同