How to select ID from table based on a value in a List?
Hello!
I wonder how to select a conditional value from a Table column that has lists of values?
Example: I have a table in the database that looks like below:
| ID | Itemname | IDList |
| 1 | TestItem | 1 7 10 17 |
For example, I want to know which Itemname it is for number 10 that is in the IDList. What should this SQL syntax look like? I have tried %INLIST and other things but only get blank value. How should the SQL-syntax for that query look like?
Greatful for all tips.
Regards,
Michael
Comments
If your IDList is a string, you'd have to use WHERE 10 %INLIST $LISTFROMSTRING(IDList,' ') so that the string is converted to an actual list for %INLIST to work.
Hi David!
It's integers-values in the list. It's actually IDs from other tables
/Michael
Hello Enrico
Thanks! It worked.
SELECT Item Name
from <Table>
WHERE FOR SOME %ELEMENT(IDList) (%VALUE=10)
cooked the steak! :0)
Regards,
Michael