我在MySQLWorkbench中有以下查询
Select * from table where col1 = "A" and col2 = "a"
Select * from table where col1 = "B" and col2 = "b"
Select * from table where col1 = "C" and col2 = "c"
Select * from table where col1 = "D" and col2 = "d"
Select * from table where col1 = "E" and col2 = "e"
我可以将这些查询放入一个像这样的查询
Select * from table where col1 = <value1> and col2 =<value2>
从文件(或某处)读取值并将其分配给查询并运行。
我认为,我可以用以下格式存储价值
A,a
B,b
C,b
D,d
E,e
答案 0 :(得分:0)
select
*
from
table
where
(col1 ='A' and col2 = 'a')
OR (col1= 'B' and col2 = 'b')
OR (col1 = 'C' and col2 = 'c')
答案 1 :(得分:0)
你可以使用:
Select
*
from
table
where
col1 IN ('A','B','C','D','E') and col2=LOWER(col1);
答案 2 :(得分:0)
就像我在评论中建议的那样,您可以使用IN
运算符:
您可以阅读有关here的更多信息。
SELECT * FROM table
WHERE col1 IN ("A", "B", "C", "D", "E") and col2 IN ("a", "b", "c", "d", "e")
答案 3 :(得分:0)
你想要一些你传递参数的东西吗?
如果是这样,以下程序将起作用
.title