1
如何與多個AND
,一個SQL CASE
語句結合起來,這樣我可以檢查多個條件,即 我想隨機233
改變region
到244
爲shopid = 455
:SQL結合案例,並與
select
id,
case region
when 233 and shopid = 455 and FLOOR(RAND()*(3-1)+1) = 1 then 244
when 233 and shopid = 455 and FLOOR(RAND()*(3-1)+1) = 2 then 233
else region
end
from
table1
我得到這個錯誤:
Operand '233' part of predicate '233 AND shopid = 455' should return type 'BOOLEAN' but returns type 'INT'.
FYI FLOOR(RAND()*(3-1)+1)
要麼產生1或2
情況下,當REGION = 233 ............. – BobSki
哪個RDBMS是這個呢?請添加一個標籤來指定您是使用'mysql','postgresql','sql-server','oracle'還是'db2' - 或者其他的東西。 –