Jump to content

Mysql WHERE command for multiple values


rahulephp

Recommended Posts

Please help me to find out the solution.

I want to fetch data from "product" table where "Product_id"(s) are 5,8,9,12...

 

I am using the query:

SELECT * FROM products WHERE product_id=5 OR product_id=7 
OR product_id=8 
OR product_id=9 
OR product_id=12 

 

But i dont want to use "product_id=" again and again many time.

 

Just wondering if there any sql syntax like "SELECT * FROM products WHERE product_id=(5,8,9,12)" ?

Above statement is only a assumption but wanted to know if there is anything possible like this.

 

Thanks in anticipation

Link to comment
https://forums.phpfreaks.com/topic/199584-mysql-where-command-for-multiple-values/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.