1

How can I compare a subquery with a column in Laravel's query builder? whereColumn method only accepts string values for columns, where method on the other hand is not suitable, as it compares a column or a subquery against a specific value.

1 Answer 1

0

Why isn't the where method suitable? You can do

DB::query()
    ->from('a_table')
    ->where('column_a', '=', function ($query) {
        $query->select('column_b')->from('some_other_table')->limit(1);
    });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.