在mysql中选择多个条件

时间:2016-05-04 08:22:20

标签: mysql

$querySelectItems = "SELECT * FROM auction_items WHERE auction_items.Itm_status = 'Pending' OR auction_items.Itm_status = 'Fail' AND Item_userid = :uid";

$stmtSelectItems = $conn->prepare($querySelectItems);   
$stmtSelectItems->bindParam(':uid',$_SESSION['userid']);                 
$stmtSelectItems->execute();

以上代码无法正常工作,我想选择 itm_status = pending还是itm_status = fail 会列出去掉,但我尝试编写上面的代码无法正常工作〜

1 个答案:

答案 0 :(得分:0)

试试这个:

$querySelectItems = "SELECT * FROM auction_items WHERE (auction_items.Itm_status = 'Pending' OR auction_items.Itm_status = 'Fail') AND Item_userid = :uid";