Hi Guys,
Due to time constraints I did very minimal search on the forums here, so I am sorry if this has been answered previously..I am just throwing it out there!
Here is what I need help with:
I have a users table and then a join table between users and some attributes (lets call this table user_attributes). Now I would like to select data from the users table with all columns from the users table along with the first attribute associated to the user as an additional column in the result.
Basically, if users X & Y have the following attributes:
User Attribute
X A
X B
X C
Y A1
Y B1
Y C1
then when I do select * from users where user= X what I would like to get is:
user_name user_something ..... attribute
X some abc ..... A
Y some abc ..... A1
That chosen attribute has to be the top 1 of the attributes associated with the user. What should I add in the select statement to get this result?
Any help on how to achieve this is greatly appreciated. Thanks in advance.
Due to time constraints I did very minimal search on the forums here, so I am sorry if this has been answered previously..I am just throwing it out there!
Here is what I need help with:
I have a users table and then a join table between users and some attributes (lets call this table user_attributes). Now I would like to select data from the users table with all columns from the users table along with the first attribute associated to the user as an additional column in the result.
Basically, if users X & Y have the following attributes:
User Attribute
X A
X B
X C
Y A1
Y B1
Y C1
then when I do select * from users where user= X what I would like to get is:
user_name user_something ..... attribute
X some abc ..... A
Y some abc ..... A1
That chosen attribute has to be the top 1 of the attributes associated with the user. What should I add in the select statement to get this result?
Any help on how to achieve this is greatly appreciated. Thanks in advance.