Reputation: 1568
How to properly use or in mysql query?
With the following query I'm trying to search for string in playlist_name and name, but it's ignoring the "playlist_name"
$search_results = mysql_query("SELECT * FROM show where playlist_name or name LIKE '%$search_string%'");
Upvotes: 0
Views: 66
Reputation: 2819
Check condition for both fields.
where playlist_name LIKE '%$search_string%'" OR name LIKE '%$search_string%'"
Upvotes: 1
Reputation: 157334
You need to use LIKE
for the first condition too
$search_results = mysql_query("SELECT * FROM show WHERE
playlist_name LIKE '%$search_string%'
OR
name LIKE '%$search_string%'");
Upvotes: 1
Reputation: 4117
where playlist_name LIKE '%$search_string%' or name LIKE '%$search_string%'
Upvotes: 1