使用列表从MySql中选择行 [英] Select rows from MySql using a list
问题描述
大家好,
我有一个包含超过100个项目的列表,例如1A100到1A250,我有一个MySQL数据库,其中一列可能包含也可能不包含列表中的项目,如果列包含列表中的任何值,则从表格中选择行。
1 | 1A100 |测试1
2 | 2A100 |测试2
3 | 1A250 |测试3
我知道函数 REGEXP和NOT REGEXP 但是列表太大所以命令文本可能超过允许的字符数限制。
任何人都可以帮助我,提前谢谢。
-Manuprasad
如果我理解你的问题,为什么不使用IN
运算符?
类似
SELECT *
FROM TableName
WHERE ColumnName IN (' 1A100',' 1A250' 跨度>,...)
Hi all,
I have a list with more than 100 items say 1A100 to 1A250 and I have a MySQL database in which one column may or may not contains an item in list, if the column contains any value from the list then select the row from the table.
1 | 1A100 | Test-1
2 | 2A100 | Test-2
3 | 1A250 | Test-3
I am aware of the functions REGEXP and NOT REGEXP but the list is too big so the command text may cross the permissible character limit.
Can anybody help me on this, thanks in advance.
-Manuprasad
If I understand your question correctly, why not useIN
operator?
Something like
SELECT * FROM TableName WHERE ColumnName IN ('1A100','1A250',...)
这篇关于使用列表从MySql中选择行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!