Support the ongoing development of Laravel.io →
posted 10 years ago
Database
Last updated 1 year ago.
0

You may use the following code:

dd($your_query->toSql());

Then access the page and your code will halt execution and dump the query as SQL syntax.

By the way, for this exact query you exemplified, the following code works:

DB::table('product')
	->join('price', 'product.productid', '=', 'price.productid')
	->leftJoin('purchaseitem', 'product.productid', '=', 'purchaseitem.productid')
	->where('product.name', '=', 'Superior King Room')
	->whereNotBetween('purchaseitem.datestart', array('2014-01-06', '2014-01-07'))
	->groupBy('product.productid')
	->having(DB::raw('count(`purchaseitem`.`productid`)'), '<', 'product.quantity')
	->take(30);
Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

cuddylover cuddylover Joined 19 Mar 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.