Two conditions in SQL query with Laravel 4

Asked

Viewed 783 times

4

I need to make a query to Mysql with two conditions. I tried to do so:

$query=DB::table('veteranos')->where('ra', '2300')->where('flag', 0)->pluck('ra');

In this way, the second condition is not working, that is, the query takes different values from 0 to flag. What would be the correct way to do this consultation?

1 answer

2


You can do two functions. The second function takes as parameter the result of the first query.

DB::table('veteranos')->where('ra', '2300')
            ->where(function($query){
                return $query
                          ->where('flag', 0)->pluck('ra');

Browser other questions tagged

You are not signed in. Login or sign up in order to post.