让我们说我有车牌,我有2列:模型,颜色。
id model color
------ -------- ----------
1 Ford yellow
2 Ford green
3 Ford red
4 Ford yellow
5 Subaru yellow
6 Subaru red
我不想拿车模型福特和黄色。我怎么能用雄辩的方式做到这一点。我需要这个条件。
WHERE NOT (model = 'Ford' AND color = 'yellow')
感谢您的帮助
答案 0 :(得分:1)
where('model', '!=', 'ford', 'AND', 'color', '!=', 'yellow')
答案 1 :(得分:0)
只需使用!=
运算符。
WHERE (model != 'Ford' AND color != 'yellow')
答案 2 :(得分:0)
试试这个......
Select * from car where NOT model = 'ford' AND NOT color = 'yellow'
这对你有用......
答案 3 :(得分:0)
试试这个......
$products = Modelname::where('model','!=','Ford')->orwhere('color','!=','yellow')->get();
Its same as
SELECT * FROM tablename WHERE model != 'Ford' OR color != 'yellow';
输出:
Array ( [0] => Array ( [id] => 0 [model] => Ford [color] => green )
[1] => Array ( [id] => 0 [model] => Ford [color] => red )
[2] => Array ( [id] => 0 [model] => Subaru [color] => yellow )
[3] => Array ( [id] => 0 [model] => Subaru [color] => red ) )