-2

I have a value

$id=10,12,4,45; //these are ids of all the products in product table

Now I want to show (echo) products' names which are given in this single variable.

Something like:

query="SELECT description from product where id ='$id' ";

How do I do that?

SecretAgentMan
  • 2,856
  • 7
  • 21
  • 41

1 Answers1

3

Use find_in_Set()

SELECT description from product where find_in_set(id,'$id')
Fahmi
  • 37,315
  • 5
  • 22
  • 31