我有一个DB如下:
name || Country || code
Los Angeles United States LAX
***Additional Services*** United Kingdom 999V
New York United States NYC
我想选择与列匹配的三列中的所有值,但隐藏以'*'开头的值。这是我的sql从三列中选择任何值,我只需要添加该部分以跳过以*开头的值。
SELECT code, name, Country FROM city_codes WHERE CONCAT(code, name, Country) LIKE '%$term%' ORDER BY name ASC
答案 0 :(得分:1)
那么,这个怎么样?
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;
答案 1 :(得分:0)
添加到where
子句
and name not like '*%'