[TYPO3-english] DB Select

JoH asenau info at cybercraft.de
Mon Oct 5 19:10:05 CEST 2009


>> I can think of 1 way to do that, but it's really really ugly.
>>
>> SELECT * FROM table2 WHERE category LIKE '%,X,%' OR category RLIKE
>> '^X,'
>> OR category RLIKE ',X$'
>
> RLIKE is not a SQL standard... just so you know....

Usually FIND_IN_SET would do the job, but this again is not SQL standard.
This is why, if at all, it should be done like this:

WHERE CONCAT(',',category,',') LIKE '%,X,%'

But this would do a fulltext search which will be quite slow compared to a
normalized version using an MM table.

HTH

Joey

-- 
Wenn man keine Ahnung hat: Einfach mal Fresse halten!
(If you have no clues: simply shut your gob sometimes!)
Dieter Nuhr, German comedian
Xing: http://contact.cybercraft.de
Twitter: http://twitter.com/bunnyfield
TYPO3 cookbook (2nd edition): http://www.typo3experts.com
TYPO3 workshops: http://workshops.eqony.com




More information about the TYPO3-english mailing list