堆栈在以下代码中的 WhereRaw 子句中
Stack in the WhereRaw clause in the following Code
whereRaw 在这里如何工作?如果只是普通 SQL?
您查询的是:
Select * from orders
Where price > IF(state='TX',200,100)
我不知道你的数据库是什么但是IF(state='TX',200,100)
意味着
if (state == 'TX')
return 200;
else
return 100;
所以如果该记录的 state
字段是 'TX'
它将被添加到查询结果 if price
该记录的字段更大超过200
otherwise (state
is not 'TX'
) 该记录将被添加到查询结果 if price
该记录的字段大于 100
whereRaw 在这里如何工作?如果只是普通 SQL?
您查询的是:
Select * from orders
Where price > IF(state='TX',200,100)
我不知道你的数据库是什么但是IF(state='TX',200,100)
意味着
if (state == 'TX')
return 200;
else
return 100;
所以如果该记录的 state
字段是 'TX'
它将被添加到查询结果 if price
该记录的字段更大超过200
otherwise (state
is not 'TX'
) 该记录将被添加到查询结果 if price
该记录的字段大于 100