Posted inTechnology / Laravel / php / Programming

Laravel whereRaw havingRaw and orderByRaw Example

Today, We want to share with you Laravel whereRaw havingRaw and orderByRaw Example.In this post we will show you How To Select Raw SQL Using Eloquent, hear for laravel selectraw bindings we will give you demo and example for implement.In this post, we will learn about Laravel Query Builder, selectRaw or select and raw with an example.

Laravel whereRaw havingRaw and orderByRaw Example

There are the Following The simple About Laravel whereRaw havingRaw and orderByRaw Example Full Information With Example and source code.

As I will cover this Post with live Working example to develop Display Raw SQL query from Query Builder in Laravel, so the some major files and Directory structures for this example is following below.

Laravel whereRaw query methods


$products = DB::table('products')
    ->whereRaw('price > IF(state = "TX", ?, 100)', [200])

Laravel havingRaw query methods


Product::groupBy('product_id')->havingRaw('COUNT(*) > 1')->get();

Laravel orderByRaw query methods


laravel orderByRaw() on the query builder

User::where('created_at', '>', '2022-01-01')
  ->orderByRaw('(updated_at - created_at) desc')
$product = "
    match (
    ) against (

$category = 'mobile';

$sql->whereRaw($product, array($category));
$sql->orderByRaw($product . " DESC", array($category));

Laravel “Where” Eloquent Examples

->where(function ($query) {
  $query->where('a', '=', 1)
      ->orWhere('b', '=', 1);
->orWhere('product_desc','!=', 'value')
->whereRaw('age > ? and repututaions = 100', array(25))

->whereRaw(DB::raw("id in (select area_code from bios GROUP BY bios.area_code)"))

      ->whereRaw('users.mang_id =')
      ->havingRaw("COUNT(*) > 0");

->whereNotIn('id', function($query){


->whereMonth('product_desc', '=', 1)
->whereYear('product_desc', '>', 2020)
->whereDate('product_desc', '>', '2025-01-01')
Web Programming Tutorials Example with Demo

Read :


You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about sql to laravel query builder online.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

Your email address will not be published. Required fields are marked *

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype