Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql WhereNot条款在laravel7中不起作用_Mysql_Laravel_Eloquent - Fatal编程技术网

Mysql WhereNot条款在laravel7中不起作用

Mysql WhereNot条款在laravel7中不起作用,mysql,laravel,eloquent,Mysql,Laravel,Eloquent,**我在下面的脚本中使用了whereNot子句。显示以下错误。除取消数据外,其余数据将显示。有人能帮我吗 SQLSTATE[42S22]:未找到列:在where子句中1054未知列“not”(SQL:select count(*)从c客户机asc用户asu在c电话营销=uid在cidd** 用这个 $datas= DB::table('client as c') ->select( 'c.id as cli

**我在下面的脚本中使用了whereNot子句。显示以下错误。除取消数据外,其余数据将显示。有人能帮我吗

SQLSTATE[42S22]:未找到列:在where子句中1054未知列“not”(SQL:select count(*)从
c
客户机
as
c
用户
as
u
c
电话营销
=
u
id
c
id
d
**

用这个

$datas= DB::table('client as c') 
                     ->select(
                    'c.id as clid',
                    'u.id as uid',
                    'd.id as did',
                    'd.bgcolor as bgcolor',
                    'd.fcolor as fcolor',
                    'c.customerName as customerName',
                    'c.email as email',
                    'c.streetaddress as streetaddress',
                    'c.city as city',
                    'c.landNumber as landNumber',
                    'u.codenumber',
                     )       
                     ->leftJoin('users as u', 'c.telemarketar', '=', 'u.id')
                     ->leftJoin('disposition as d', 'c.id', '=', 'd.client')
                     ->where('bgcolor','<>','CANCEL')
                     ->orderBy('c.id', 'desc')        
                     ->paginate(100); 
$datas=DB::table('client as c')
->挑选(
“c.id作为clid”,
“u.id作为uid”,
“d.id如我所做”,
“d.bgcolor作为bgcolor”,
“d.fcolor作为fcolor”,
“c.客户名称作为客户名称”,
“c.电子邮件作为电子邮件”,
“c.streetaddress作为streetaddress”,
“c.城市即城市”,
“c.landNumber作为landNumber”,
'美国代码',
)       
->leftJoin('用户身份为u','c.telemarketar','=','u.id')
->leftJoin('处置为d','c.id','=','d.client')
->其中('bgcolor','','CANCEL')
->订货人('c.id','desc')
->分页(100);
在Laravel中没有
whereNot()
函数。您正在寻找:

...
->where('bgcolor', '!=', 'CANCEL')
...
出现该错误的原因是
->where{noon}()
是Laravel中的一个神奇函数,其中
{noon}
用作查询中的列(除非它作为特定函数存在,如
->whereHas()

由于没有
->whereNot()
函数,它使用
not
作为列:名称:

WHERE `not` ...

这是无效的,因为您的表确实没有
not
列。

是的,了解如何解决这个问题以及正确的代码将
->whereNot('bgcolor','=','CANCEL')
替换为
->where('bgcolor','!=','CANCEL')
,正如我在回答中所说的…->where('bgcolor','!=','CANCEL)我用过这个,但我没有得到所有的数据。这是一个单独的问题。我提供的答案是为了解决您发布的错误。如果错误消失了,请考虑接受这个答案并结束你的问题。如果您想将问题更改为“为什么我没有获取数据”,则必须对问题进行大量修改,这将使答案无效,并且不利于如何使用Stackoverflow。
WHERE `not` ...