Lorenz, Hr. wrote: > > Hi all, > > I have a problem and I'm not really sure if I can solve it > with SQL/SAPDB: > > I have a field HAYSTACK (varchar) in my table and a query > that returns n > NEEDLES (integer). > Is it possible to check if one of the NEEDLE-Values is in the > HAYSTACK-String? > > Example: > Haystack: '1;2;3;4;5;' > Needle-Resultset: 2 / 4 / 7 => tricky function that > returns TRUE > 'cause a needle-value is in Haystack > > Do anyone of you know a way to achieve this? > > (using a asociative table for haystack could solve this, but > is this really > neccesary? it seems to me a little bit oversized...) > > Thanks in advance > > S. Lorenz
If we are talking about numbers consisting of exactly one digit, you could use select distinct haystack-column from haystack, needles where haystack-column like '%'||chr(needles-column)||'%' if more than one digit is available like '%;'||chr(needles-column)||';%' would be ok if the first value in haystack had a ; in front, otherwise the above like AND like 'chr(needles-column)||';%' had to be added (but with not so nice performance). Elke SAP Labs Berlin -- MaxDB Discussion Mailing List For list archives: http://lists.mysql.com/maxdb To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]
