Need help with leftjoin statement.

Need help with leftjoin statement.

pinowskipinowski Posts: 2Questions: 1Answers: 0

I'm drawing a blank on this. I can get the following leftjoin to work, but I want to limit the data to only users in the table with an "admin" column set to true in the database. I'm not sure if I should use the where statement and if so, what to put in place of the ???. I've experimented with no success other than having the leftjoin work. Thanks.

->leftJoin('users', 'users.user_id', '=', 'jobs.user_id')
->where('users.???', $_POST['???'])

->process( $_POST )
->json();

Answers

  • allanallan Posts: 61,971Questions: 1Answers: 10,160 Site admin

    I think:

    ->where('users.admin', 1)
    

    should be all that is needed (where 1 is boolean true to the db).

    Allan

  • pinowskipinowski Posts: 2Questions: 1Answers: 0

    The value in the db is not boolean for some reason. It's a VARCHAR (i.e., YES or NO). I tried the following, but it did not exclude those with a NO valuel

    ->where('users.is_admin', 'YES')

  • allanallan Posts: 61,971Questions: 1Answers: 10,160 Site admin

    Could you show me the whole of the PHP please? That looks like it should work.

    Allan

This discussion has been closed.