
September 12th, 2012, 04:02 PM
|
|
Registered User
|
|
Join Date: Sep 2012
Posts: 1
Time spent in forums: 3 m 36 sec
Reputation Power: 0
|
|
|
Help needed please - SELECT ALL WHRE id IN (array from another table record)
Hi Smart People,
Here is my puzzle ....
I would like to store an array of comma separated numbers in a user table, and then use this array of numbers to SELECT ALL IN another table.
Example:
Table:USERS
id = [6 ]| favorites = [1,2,4,5,]
Table: FAVORITES
id = [1] | fav = [DOGS]
id = [2] | fav = [CATS]
id = [3] | fav = [FISHS]
id = [4] | fav = [PAROTS]
id = [5] | fav = [MONKEYS]
id = [6] | fav = [HORSES]
id = [7] | fav = [SHEEP]
Desired RESULT =
USER 6 likes DOGS,CATS,PARROTS,MONKEYS
Is this Possible?
Can someone help me with the correct way to write this SQL statement?
Can this be a stored Procedure?
All help gratefully received.
Coddii
|