For Programmers: Free Programming Magazines  


Home > Archive > PHP SQL > March 2005 > SQL-Query









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author SQL-Query
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.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com