I want to do something like "Where conditions = '$condition' OR conditions = '$condition2' OR conditions = '$condition3' but that returns all entries in the database versus the ones i am looking for.. what i can i do to make this work?
$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.p开发者_运维百科erson_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);
you may use parenthesis to group up your logic.
just continuing to list OR statements will match the rows if any of those are true.
Where conditions in ('$condition1', '$condition2', '$condition3')
精彩评论