Andrew Dixon <[EMAIL PROTECTED]> wrote: >Hi Everyone. > >I require some help with an IN statement I'm trying to get working. I have >inherited a database from someone else in which there is a table with >project information and a field containing which geographic regions the >projects relate. As a single project can relate to multiple geographic >regions the person who created the database create this field as a varchar >field and populated it with a pipe (|) delimited list of ID's of the >geographic regions (ID from another table). An example of the data in this >field is: > >1|5|9|10|12 > >Or > >1 > >Or > >9|5|7 > >I have been asked to write a query to return all the projects for a single >geographic region. This is what I have come up with: > >SELECT project_title >FROM projects >WHERE 9 IN (REPLACE(geo_region,'|',',')) >ORDER BY project
[...] I would suggest something like WHERE CONCAT('|',geo_region,'|') LIKE '%|9|%' - seb -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]