I write a query. It is work but i need to add one more column.
So, my sql query like is :
AND TESTTEST(coName, 3) IN ('1','2')
I try
->whereIn("coName",[1,2])
but how to use select(coName,3) ?
->whereIn("coName",[1,2])
->get();
or Can I just directly run my query like is: ->whereRaw("TESTTEST(coName, 3) IN ('1','2')")
Is this a way?
CodePudding user response:
you can directly run raw query as
Model::whereRaw()->get();
or you can chain the where clause one after other. to get your desired result. In Eloquent you do not have to specify the column number for your column. you can write the query as
Model::where()->where()->get();
CodePudding user response:
Also when you have multiple condition you can do this:
Model::whereIn('coName', [1,2])->where(['col1' => 'val1', 'col2' => 'val2'])->get();