SQL Like 子查询 [英] SQL Like with a subquery
本文介绍了SQL Like 子查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我怎样才能做到这一点?
How can i make this work?
SELECT *
FROM item
WHERE item_name LIKE '%'
|| (SELECT equipment_type
FROM equipment_type
GROUP BY equipment_type)
|| '%'
内部子查询返回一个字符串列表,如'The' 'test' 'another',我想从 item_name 类似于子查询返回值的项目表中选择所有项目.我需要通配符.
The inner sub query returns a list of strings like 'The' 'test' 'another' and i want to select all items from the item table where the item_name is similar to the sub queries return values. I need to have the wild cards.
是否有替代方法可以使用通配符但使用 IN sql 命令?
Is there an alternative where i can use wildcards but use the IN sql command instead?
推荐答案
您可以使用 INNER JOIN
:
SELECT I.*
FROM item I
INNER JOIN (SELECT equipment_type
FROM equipment_type
GROUP BY equipment_type) E
ON I.item_name LIKE '%' || E.equipment_type || '%'
这篇关于SQL Like 子查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文