Important SQL Operators || Steem Alliance Community.

in hive-150122 •  7 months ago 

Hello Everyone,


Blue Gradient Company Business Profile Presentation.jpg

How are you, I hope you guys will happy and well. By the grace of God, I am also well. Today I am here with new post of SQL and PL/SQL series in which i am going to discuss SQL operators that will used in where clause.

Different SQL operators are mentioned below.

  • LIKE
  • IN
  • BETWEEN

LIKE OPERATOR

First of all, we discuss about the LIKE operator, why we use it in SQL and how much worth it have in report building. LIKE operator are used to search data from a column for a specified pattern. The percent % sign is used with like operator to find the specific type of data.

For example, I have a table with multiple rows and columns. I want to filter out the data using like operator.

Nosectorcust_idname_1Town
110004270603SIKANDARPESHAWAR
210004270939ALI TARIQALI PUR
310005715170ALI HAMZAGALA YOUSAF
410007796882IMRANKHANEWAL
51000953045UMARYAZMAN

Now we use the LIKE operator then see the result



select sector , cust_id , name_1 , Town from users  where  name_1 LIKE '%ALI%'


I am applying the LIKE operator on name_1 column to filter out those data rows who have "ALI" name. it does not meter where it exists in the data of column. To filter out data rows where the name contains "ALI" in the name_1 column regardless of its position within the data, we will use the '%' wildcard on both sides of "ALI" within the LIKE operator.

Nosectorcust_idname_1Town
110004270939ALI TARIQALI PUR
210005715170ALI HAMZAGALA YOUSAF

In the above result. we can see that it selects all rows where the name_1 column contains "ALI" anywhere within its data.

IN OPERATOR

IN Operator is used to perform the specific operation by using multiple filters in where clause. basically, it fulfils the OR operator operations. It allows us to specify a list of values that we want to match against any subjected column.

For example, we want to filter out those data whose cust_id is equal to (5715170 , 4270939 ).


select * from users  where cust_id in  ('5715170 ' , '4270939' ) ;


Nosectorcust_idname_1Town
110004270939ALI TARIQALI PUR
210005715170ALI HAMZAGALA YOUSAF


sql-like.webp
Img Src

BETWEEN OPERATOR

BETWEEN operator is commonly used to filter data within a specific range, especially when dealing with date or timestamp data types. It is the best way to query for records that fall within a particular period or interval. By specifying the start and end points of the range, we can easily retrieve data that meets our criteria without needing to construct complex conditions manually.

SELECT * FROM tables WHERE date BETWEEN '10-JAN-24' AND '20-JAN-24';

It would be my pleasure if you will share your opinion and reviews on this topic

20230310_190323_0000.png

Please cast witness vote to @bangla.Witness or set proxy to @rme.

_
Vote @bangla.witness as witness
Set Proxy @rme as proxy

Special Thanks.

Cc: @rme
Cc: @hungry-griffin
Cc: @steemcurator02

Thanks for giving your precious time to my post.
Follow | Upvote | Share | Comments
Follow me on Instagram.
Instagram

🆃🅷🅰️🅽🅺 🆈🅾️🆄

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!