| Roman Blöth 2005-03-24, 8:57 am |
| Hello sql'ers,
I'm trying to create an SQL-query combining data from two different
tables in my db, but can't find the correct syntax. Hopefully someone
here can help me a bit:
First table:
tbl groups: id(int), group(tinytext), labels_ids(text)
like so:
id........: 12
group.....: 'Fashion Men->Accessoires'
labels_ids: '51,13,46,52,47,53'
Second table:
tbl labels: id(int), label(tinytext)
like so:
id...: 13
label: 'Lanvin'
What I want to extract is a list of all 'groups.group','labels.label'
where 'labels.id' in 'groups.labels_ids', so I can see which (fashion-)
'label's there are for each 'group'.
What I thought of does not work at all:
SELECT labels.id, group , labelslist
FROM labels, groups
WHERE labels.id IN labelslist
Someone got a hint for me?
Any comment welcome,
Roman.
|