Your Guide to Laravel Excellence

Faster Query with `whereIntegerInRaw` Method

Faster Query with `whereIntegerInRaw` Method

In this article we will learn about whereIn and whereIntegerInRaw, both these methods are used to add a "where in" clause to your database queries.

whereIn Method

The whereIn method is typically used for standard queries where the column can be any data type (string, integer, etc.).

DB::table('users') ->whereIn('id', [1, 2, 3])->get();

The whereIntegerInRaw method is very useful where the column is an integer and you need a more efficient query.This method can be useful when you are working with a large set of integers.

DB::table('users')->whereIntegerInRaw('id', [1, 2, 3])->get();

Summary

  • whereIn can handle various data types.

  • whereIntegerInRaw is optimized for integer columns

  • Use whereIn when you are dealing with columns that might not strictly be integers or when the set of values includes different data types.

  • Use whereIntegerInRaw when you are sure that the column and the values are integers.

Recommeded Posts

Laravel 11 Stopping Validation on First Failure

Laravel 11 Stopping Validation on First Failure

Laravel 11 Stopping Validation on First Failure

4 months ago Read article →
Model Change Tracking in Laravel 11 - Laravel Auditing

Model Change Tracking in Laravel 11 - Laravel Auditing

Model Change Tracking in Laravel 11 - Laravel Auditing

4 months ago Read article →
Convert mp4 to m3u8 using FFMpeg for Laravel with AWS S3

Convert mp4 to m3u8 using FFMpeg for Laravel with AWS S3

Convert mp4 to m3u8 using FFMpeg for Laravel with AWS S3

4 months ago Read article →
LinkedIn OAuth Authentication in Laravel Without Socialite

LinkedIn OAuth Authentication in Laravel Without Socialite

LinkedIn OAuth Authentication in Laravel Without Socialite

4 months ago Read article →