Jul 24, 2009 #1 wimkumpen Programmer Jun 13, 2009 8 BE Hello, I have a varchar field where the values look like: "5,3,9" I want to use those values in a 'where in': select * from tabel where id in (varcharfield) is something like this possible?
Hello, I have a varchar field where the values look like: "5,3,9" I want to use those values in a 'where in': select * from tabel where id in (varcharfield) is something like this possible?
Jul 24, 2009 #2 r937 Technical User Jun 30, 2002 8,847 CA it is possible, but horribly clumsy and inefficient WHERE CONCAT(',',varcharfield,',') LIKE CONCAT('%,',id,',%') your problem is the comma-delimited string of values stored in a single column, which violates first normal form any chance you could redesign that? r937.com | rudy.ca Buy my new book Simply SQL from Amazon Upvote 0 Downvote
it is possible, but horribly clumsy and inefficient WHERE CONCAT(',',varcharfield,',') LIKE CONCAT('%,',id,',%') your problem is the comma-delimited string of values stored in a single column, which violates first normal form any chance you could redesign that? r937.com | rudy.ca Buy my new book Simply SQL from Amazon
Jul 24, 2009 #3 DonQuichote Programmer Nov 9, 2001 980 I think I would use the FIND_IN_SET function in such a case. +++ Despite being wrong in every important aspect, that is a very good analogy +++ Hex (in Darwin's Watch) Upvote 0 Downvote
I think I would use the FIND_IN_SET function in such a case. +++ Despite being wrong in every important aspect, that is a very good analogy +++ Hex (in Darwin's Watch)
Jul 24, 2009 Thread starter #4 wimkumpen Programmer Jun 13, 2009 8 BE I think both solutions can be used. But the FIND_IN_SET is a little bit cleaner to use. Thanks for your help. Upvote 0 Downvote
I think both solutions can be used. But the FIND_IN_SET is a little bit cleaner to use. Thanks for your help.
Jul 24, 2009 #5 r937 Technical User Jun 30, 2002 8,847 CA and both will not scale, i.e. the more rows you have, the slower it gets r937.com | rudy.ca Buy my new book Simply SQL from Amazon Upvote 0 Downvote
and both will not scale, i.e. the more rows you have, the slower it gets r937.com | rudy.ca Buy my new book Simply SQL from Amazon