我需要一个逻辑来根据字符串搜索列。
考虑以下查询。在下面的查询中,我想在customer表中搜索字符串'test'。如果在客户名称列中找到它,则需要位于顶部,然后是基于customer_slug找到的列
SELECT * FROM `customer_list` WHERE customer_name = 'test' UNION
SELECT * FROM `customer_list` WHERE customer_slug = 'test'
答案 0 :(得分:1)
SELECT * FROM customer_list
where 'test' in (customer_name, customer_slug)
order by 'test' <> customer_name,
'test' <> customer_slug
答案 1 :(得分:0)
"URL with ' "