Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel where in subquery

DB::table('users')
    ->whereIn('id', function($query)
    {
        $query->select(DB::raw(1))
              ->from('orders')
              ->whereRaw('orders.user_id = users.id');
    })
    ->get();

This will produce:

select * from users where id in (
    select 1 from orders where orders.user_id = users.id
)
Comment

laravel subquery in from clause

DB::table(DB::raw("({$query->toSql()}) as alias") )
Comment

subquery in laravel

1AVG(SUM(amount))
Comment

PREVIOUS NEXT
Code Example
Php :: php query 
Php :: laravel 6 migration add column to existing table 
Php :: laravel jobs tutorial 
Php :: how to print any string in double quotes in php 
Php :: stripslash 
Php :: php catch mysqli_connect(): (HY000/1045): Access denied 
Php :: laravel get only validated data 
Php :: Turn error log WP 
Php :: loop through object php 
Php :: learn php 
Php :: php check if passwords match 
Php :: schema add column laravel 
Php :: declare variable in view for loop laravel 
Java :: how to iterate through an array backwards java 
Java :: java get next enum 
Java :: import android.support.v7.app.ActionBarActivity; 
Java :: spigot custom join message 
Java :: how to create new frame with java swing 
Java :: starting code of java 
Java :: Card view implement 
Java :: How to solve towers of hanoi problem? 
Java :: transparent background android studio 
Java :: convert a string to int in java 
Java :: capcitor FERR_CLEARTEXT_NOT_PERMITTED 
Java :: how to measure the running time of a code section in java? 
Java :: How do you print duplicate characters from a string? 
Java :: edittext hint color 
Java :: processing draw circle 
Java :: where is java installed in ubuntu 
Java :: android parse timestamp 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =