Can mix where() clauses


Sarasi

I have the following code (shortened otherwise it would take too long to display):

Feedback::find()
        ->where(['feedback.fg_id' => $this->id])
        ->orWhere(['feedback.fg_id' => $this->id, 'feedback.closed_time' => NULL, '<' => ['feedback.survey_end_date', new Expression('NOW()')]])
        ->all();

This code is not working because of the last statement inorWhere()

My question now is: how do I put the syntax together orWhere? This is because I need all the statements orin the block .

The contradictory sql code should be:

SELECT * FROM feedback WHERE
(feedback.fg_id = 1) OR (feedback.fg_id = 1 AND feedback.closed_time IS NULL AND feedback.survey_end_date < NOW())
double H

Yes, you can combine your own terms because...

Feedback::find()
->where(['feedback.fg_id' => $this->id])
->orWhere(['AND',
    ['feedback.fg_id' => $this->id],
    ['feedback.closed_time' => NULL],
    ['<' , 'feedback.survey_end_date', new Expression('NOW()')]
 ]);

Related


Can mix where() clauses

Sarasi I have the following code (shortened otherwise it would take too long to display): Feedback::find() ->where(['feedback.fg_id' => $this->id]) ->orWhere(['feedback.fg_id' => $this->id, 'feedback.closed_time' => NULL, '<' => ['feedback.surv

Can mix where() clauses

Sarasi I have the following code (shortened otherwise it would take too long to display): Feedback::find() ->where(['feedback.fg_id' => $this->id]) ->orWhere(['feedback.fg_id' => $this->id, 'feedback.closed_time' => NULL, '<' => ['feedback.surv

Can mix where() clauses

Sarasi I have the following code (shortened otherwise it would take too long to display): Feedback::find() ->where(['feedback.fg_id' => $this->id]) ->orWhere(['feedback.fg_id' => $this->id, 'feedback.closed_time' => NULL, '<' => ['feedback.surv

Can mix where() clauses

Sarasi I have the following code (shortened otherwise it would take too long to display): Feedback::find() ->where(['feedback.fg_id' => $this->id]) ->orWhere(['feedback.fg_id' => $this->id, 'feedback.closed_time' => NULL, '<' => ['feedback.surv

Can mix where() clauses

Sarasi I have the following code (shortened otherwise it would take too long to display): Feedback::find() ->where(['feedback.fg_id' => $this->id]) ->orWhere(['feedback.fg_id' => $this->id, 'feedback.closed_time' => NULL, '<' => ['feedback.surv

Can mix where() clauses

Sarasi I have the following code (shortened otherwise it would take too long to display): Feedback::find() ->where(['feedback.fg_id' => $this->id]) ->orWhere(['feedback.fg_id' => $this->id, 'feedback.closed_time' => NULL, '<' => ['feedback.surv

Can I use "virtual columns" in Where clauses?

sultani I have this query: set @last_uid = 0; set @last_tm = '00:00'; set @last_vid = 0; SELECT v.*, CASE WHEN @last_uid = visitorid AND cast( @last_tm as datetime) >= subtime( timestamp, '01:00' ) THEN if( (@last_tm := timestamp ), @last

Can SELECT and WHERE LINQ clauses be combined?

Bryce Here's what I do with the Selectuser and then delete all nullrecords : model.Users = users .Select(u => { var membershipUser = Membership.GetUser(u.UserName); return membershipUser != null

Can where clauses be combined when using whereAutogenerate?

username I would like to incorporate these into the where clause. When AutoGenerateWhereClause is true, I get the error Where property is not supported by LinqDataSource. The first where clause comes from the allocation table. I only want to select rows where

Can where clauses be combined when using whereAutogenerate?

username I would like to incorporate these into the where clause. When AutoGenerateWhereClause is true, I get the error Where property is not supported by LinqDataSource. The first where clause comes from the allocation table. I only want to select rows where

Can where clauses be combined when using whereAutogenerate?

username I would like to incorporate these into the where clause. When AutoGenerateWhereClause is true, I get the error Where property is not supported by LinqDataSource. The first where clause comes from the allocation table. I only want to select rows where

Anonymous functions cannot mix clauses

zero_coding I created a module like this: defmodule Sum do def sum(x,y) do x + y end def sum(x) do x end end Of course it works with pattern matching as I would expect: iex(2)> Sum.sum(3) 3 iex(3)> Sum.sum(3,5) 8 When I def

Anonymous functions cannot mix clauses

zero_coding I created a module like this: defmodule Sum do def sum(x,y) do x + y end def sum(x) do x end end Of course it works with pattern matching as I would expect: iex(2)> Sum.sum(3) 3 iex(3)> Sum.sum(3,5) 8 When I def

Anonymous functions cannot mix clauses

zero_coding I created a module like this: defmodule Sum do def sum(x,y) do x + y end def sum(x) do x end end Of course it works with pattern matching as I would expect: iex(2)> Sum.sum(3) 3 iex(3)> Sum.sum(3,5) 8 When I def

Anonymous functions cannot mix clauses

zero_coding I created a module like this: defmodule Sum do def sum(x,y) do x + y end def sum(x) do x end end Of course it works with pattern matching as I would expect: iex(2)> Sum.sum(3) 3 iex(3)> Sum.sum(3,5) 8 When I def

Anonymous functions cannot mix clauses

zero_coding I created a module like this: defmodule Sum do def sum(x,y) do x + y end def sum(x) do x end end Of course it works with pattern matching as I would expect: iex(2)> Sum.sum(3) 3 iex(3)> Sum.sum(3,5) 8 When I def

Anonymous functions cannot mix clauses

zero_coding I created a module like this: defmodule Sum do def sum(x,y) do x + y end def sum(x) do x end end Of course it works with pattern matching as I would expect: iex(2)> Sum.sum(3) 3 iex(3)> Sum.sum(3,5) 8 When I def

Anonymous functions cannot mix clauses

zero_coding I created a module like this: defmodule Sum do def sum(x,y) do x + y end def sum(x) do x end end Of course it works with pattern matching as I would expect: iex(2)> Sum.sum(3) 3 iex(3)> Sum.sum(3,5) 8 When I def

Indexes for where clauses and join clauses

Olivier De Meulder Consider the following: Table 1 contains the following columns: a, b, m Table 2 with the following columns: a, b, x, y Here is my query: select t2.a, t2.b, t1.m from table2 t2 join table1 t1 on t1.a = t2.a and t2.b = t2.b wher

Indexes for JOIN and WHERE clauses

Rolle If my query looks like: SELECT * FROM member LEFT JOIN group ON (member.group_id = group.id) WHERE group.created > @date ORDER BY member.last_updated If I create two indexes: member.group_id, member.last_updated group.id, group.created Is this the bes

Laravel multiple WHERE clauses

Lakmal Premaratne I need to add multiple where clauses to a Laravel SQL query. My PHP code so far is: date_default_timezone_set('America/Los_Angeles'); $today = getdate(); $year = $today['year']; $month = $today['mon']; $day = $today['mday']; $today_ = $day.

Location and efficiency of ON and WHERE clauses

you I have two tables, one called Health_User and the other called Diary . They each have the user's demographics and their recorded values. What I want to do is retrieve the value of the record, but: Deduct tests (not real users) with "is_tester" column (bool

Multiple where clauses

Priya I have the following table: ID Key Value 1 From x 1 To Y 1 CC a 2 From Z 2 To X 2 CC b 3 From X 3 To Y 3 CC c 4 From X 4 To Z 4 CC d I want Id 1 and 3 as res