Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 pull item from CSV list in field

Author  Topic 

HyperXP
Starting Member

1 Post

Posted - 2007-02-09 : 10:11:11
Hi.

You where recommended by a workmate. I hope you can help.

Now me being the lazy sod that i am used a code generator to create a back end for my website.

in the master table i have a field holding csv values eg 1, 3, 5
these relate to a sub table holding the relevant text value for the id's.

This is displayed on the page as a multiline multi selectable listbox.

Works fine in the generated code. no need to change it.

I display these values on the page by looping the values and building a sentence.

My problem....

In sql query, how could i say, return all rows where '1' is in the feild containing the csv values.

I understand searching '1' would return 1, 12, 11, 21 etc... this is true when i tried to use like.

thanks for your time guys.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-02-09 : 10:13:59
select * from yourtablename
where ',' + csvvaluelistcolumn + ',' LIKE '%,' + @YourSearchValueHere + ',%'


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-02-09 : 10:16:09
select * from yourtablename
where instr(",1,", "," & csvvaluelistcolumn & ",") > 0


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -