2 mysql查询中的where语句

时间:2013-02-08 17:52:14

标签: php mysql sql select

我无法创建查询。如何在一个中创建两个选择?

select * from messages where id ='1' and where recd = '0'

感谢

3 个答案:

答案 0 :(得分:6)

仅使用一个WHERE条款,条件按AND/OR分隔,具体取决于您的需求。

SELECT * 
FROM   messages 
WHERE  id ='1' AND recd = '0'

答案 1 :(得分:1)

试试这个::

select * from messages where id ='1' and recd = '0'

答案 2 :(得分:1)

如果 id recd 字段是数字值,您可以/应该避免使用'(单引号)来获得更好的索引搜索效果。< / p>

select * from messages where id = 1 and recd = 0;

在当前的查询案例中,MySQL足够先进,可以管理这个字符串/数字转换。

希望这会有所帮助。