Reputation: 1507
I have a DB as follows:
name || Country || code
Los Angeles United States LAX
***Additional Services*** United Kingdom 999V
New York United States NYC
I want to select all values in the three columns that match a term but hide the ones that start with '*'. This is my sql to select any value from the three columns, I just need to add the part to skip the values that start with *.
SELECT code, name, Country FROM city_codes WHERE CONCAT(code, name, Country) LIKE '%$term%' ORDER BY name ASC
Upvotes: 0
Views: 1706
Reputation: 1270421
Well, how about this?
SELECT code, name, Country
FROM city_codes
WHERE CONCAT(code, name, Country) LIKE '%$term%' and
code not like '*%' and name not like '*%' and country not like '*%'
ORDER BY name ASC;
Upvotes: 1