我想做一些类似“Where conditions ='$ condition'或条件='$ condition2'或条件='$ condition3'但会返回数据库中的所有条目与我正在寻找的条目..我是什么我可以做到这一点吗?
$sql = "SELECT STRAIGHT_JOIN DISTINCT table1.person_id, table1.full_name,
table2.stuff_id, table2.stuff_name, table3.whatever_why,
table3.whatever_comments, table3.whatever_test_id
from table1
join table4 on table1.person_id = table4.person_id
join table2 on table4.stuff_id = table2.stuff_id
join table3 on table1.person_id = table3.person_id
WHERE conditions = '$condition' and ( (
table3.whatever_why like '%$q%'
OR table3.whatever_comments like '%$q%'
OR table3.whatever_name like '%$q%'
))
order by table3.id DESC limit $startrow, 10";
$result = mysql_query($sql);
答案 0 :(得分:3)
您可以使用括号对逻辑进行分组。
继续列出OR语句将匹配行,如果其中任何一行为真。
答案 1 :(得分:1)
Where conditions in ('$condition1', '$condition2', '$condition3')