现在我有以下SQL:
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?