1

In my database table I have 6 Columns id(auto),title,news,image,type I write this query.

select id,title,image 
from add_news 
where FIND_IN_SET('Travel','Music',type) 
ORDER BY id DESC

I am getting this error

Incorrect parameter count in the call to native function 'FIND_IN_SET'
Saharsh Shah
  • 28,687
  • 8
  • 48
  • 83
Hirdesh
  • 163
  • 4
  • 16
  • The error is pretty clear. And even the most cursory Google search brings you to the documentation for that function: http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_find-in-set – David Dec 22 '14 at 13:10
  • 1. See normalization – Strawberry Dec 22 '14 at 13:18

2 Answers2

3

I am guessing that type is a comma-delimited list. This is a very poor data format, and you should have a separate table with one row per type and article.

But, given the format, the correct syntax is:

select id, title, image
from add_news
where find_in_set('Travel', type) > 0 or
      find_in_set('Music', type) > 0
order by id desc;
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
1

Use IN operator instead of FIND_IN_SET()

Try this:

SELECT A.id, A.title, A.image 
FROM add_news A
WHERE A.type IN ('Travel', 'Music')
ORDER BY A.id DESC
Saharsh Shah
  • 28,687
  • 8
  • 48
  • 83