現在我有以下SQL:有什麼辦法可以在SQL中結合LIKE和IN?
select MAX(score) as score, title from
(
select 2 as score, title from tableName WHERE title LIKE '%railway employee%'
union
select 1 as score, title from tableName WHERE title LIKE '%railway%'
union
select 1 as score, title from tableName WHERE title LIKE '%employee%'
) as t1
group by title
order by score DESC
我希望能夠做這樣的事情:
select MAX(score) as score, title from
(
select LEN(CurrentTerm) as score, title from tableName WHERE title LIKE IN ('%railway employee%', '%railway%', '%employee%')
) as t1
group by title
order by score DESC
的CurrentTerm
將是匹配的期限,而不是在表中的列。 SQL中有什麼甚至是遠程類似的東西,特別是MySQL?
我想你可以使用正則表達式而不是'LIKE IN'。 –
根據查詢,數據庫中顯示缺少正常狀態。更好的數據庫結構可能是最佳解決方案。 –