我使用以下语句:
$statement = mysql_query("SELECT * FROM `my_table` WHERE
`name` LIKE '%".$searchVal."%'
|| `street` LIKE '%".$searchVal."%'
|| `description` LIKE '%".$searchVal."%'
|| `longname` LIKE '%".$searchVal."%'
ORDER BY id");
我想添加另一个条件,只搜索type
= 500,600,700,800
答案 0 :(得分:1)
||
是一个连接运算符,我认为您打算使用OR
条件,如
SELECT * FROM `my_table`
WHERE (`name` LIKE '%".$searchVal."%'
OR `street` LIKE '%".$searchVal."%'
OR `description` LIKE '%".$searchVal."%'
OR `longname` LIKE '%".$searchVal."%')
AND `type` IN (500,600,700,800) <-- extra condition
ORDER BY id;