如何使用通配符 (LIKE) 和数组 (IN) 进行选择? [英] How to SELECT using both wildcards (LIKE) and array (IN)?
本文介绍了如何使用通配符 (LIKE) 和数组 (IN) 进行选择?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 SQL 中,如果要使用通配符执行 SELECT,可以使用:
In SQL, if you want to perform a SELECT with a wildcard, you'd use:
SELECT * FROM table_name WHERE field_name LIKE '%value%'
如果您想使用一组可能的值,您可以使用:
If you wanted to use an array of possible values, you'd use:
SELECT * FROM table_name WHERE field_name IN ('one', 'two', 'three')
但是,如果您想同时使用通配符和数组,您会怎么做?
But, what would you do if you wanted to use both wildcards AND an array?
有点像:
SELECT * FROM table_name WHERE field_name LIKE IN ('%one', '_two', 'three[abv]')
推荐答案
SELECT *
FROM table_name
WHERE field_name LIKE '%one'
OR field_name LIKE '_two'
OR field_name LIKE 'three[abv]'
这篇关于如何使用通配符 (LIKE) 和数组 (IN) 进行选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文