1

I have a MySQL table which contains comma-separated values like this:

first row=(A,AB)
second row=(AC, AE)

I want to select the rows which have A in their set not AC OR AE. I am using symfony2 in my code.

$query = $query->andWhere("FIND_IN_SET('".trim($tag)."',advNews.advNewsTags)");

Its Return Error: Expected known function, got 'FIND_IN_SET'

But if i use query in sqlyog like

select * from advice_news where  adv_news_type = 'news' AND FIND_IN_SET  ('sdf',adv_news_tags)

its work fine.

Tell me any solution i will use FIND_IN_SET in symfony2.

Addy
  • 998
  • 4
  • 12
  • 36
  • Just to be sure, you have no possibility to update the current database schema ? – A.L Jan 19 '14 at 21:34
  • 1
    You may use the `expr()->like()` function but it will work only if the string of the tag won't be a substring of another tag. For example, if you search `%animal%` it will also match with `%animals%`. – A.L Jan 19 '14 at 21:37

1 Answers1

1

You need to add FunctionNode to Doctrine and Symfony. I had the same problem with SOUNDS LIKE. You can find my solution at http://piotrpasich.com/full-text-searching/ in SOUNDEX chapter.

matteocng
  • 72
  • 2
  • 2
  • 11
Piotr Pasich
  • 2,639
  • 2
  • 12
  • 14