How can I do complex WHERE in a LEFT JOIN with Editor 1.3.2

How can I do complex WHERE in a LEFT JOIN with Editor 1.3.2

phikuphiku Posts: 8Questions: 2Answers: 0
edited August 2014 in Editor

Hi there,

i have problems gernerating a complex query with editor in the php backend.

I want something like this:

SELECT * FROM T1 LEFT JOIN T2 ON (T1.f_t2key = T2.t2key AND T2.owner='a');

I want all DATA FROM T1 - even though there are not joinable values for it in T2.
If there are joinable information on T2 i want just the ones that fit to my where condition.

Any hint for me ?

Thank you in advance,
Phil

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    Hi Phil,

    What you could do is use the where() method in Editor I think, although that would product a JOIN ... WHERE ... statement. Would that match your needs?

    Allan

  • phikuphiku Posts: 8Questions: 2Answers: 0
    edited August 2014

    Hi allan,

    thank you for your answer.
    Yes - adding the WHERE Condition to the JOIN solved it for me.

    It Looks like:

    ->join(
    Join::inst( 'T2', 'object' )
    ->join( 'pKeyT1', 'f_pKeyT1' )
    ->fields(
    Field::inst('T2Owner')->set(false),
    Field::inst('T2ValA'),
    Field::inst('T2ValB')->set(false)
    )
    ->where('T2Owner','<myCriteria>','=')
    )

    Thank you very much.

    Phil

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Answer ✓

    Good stuff - thanks for letting me know.

    Allan

This discussion has been closed.