下按預期工作:mysql的變量具有多個值時,有存儲在一個變量的單個值
Set @var = 121;
select * from table where id = @var;
如何設置有多個變量的值,然後在查詢中使用它。我曾經試過,但它不工作:
set @var = (
117,120,121,122,143,151,175,233,387,189,118,119,339,357,500,501,493,425,307,191,
117,120,121,122,143,151,175,233,387,189,118,119,339,357,500,501,493,425,307,191,
117,120,121,122,143,151,175,233,387,189,118,119,339,357,500,501,493,425,307,191
)
select * from table where id = @var;
這會引發一個「錯誤1241(21000):操作數應該包含1列」。 –