Mysql subquery fails, need help :)

myrtletoad

New Member
I have a table \[code\]PICTURES\[/code\]:\[code\]username varchar(50) picture_id varchar(50) datetime \[/code\]...and I have a table \[code\]FRIENDS\[/code\]:\[code\]user_1 varchar(50) user_2 varchar(50) datetime \[/code\]When you have friends on the website your username goes in \[code\]user_1\[/code\], and your friend username's go in \[code\]user_2\[/code\]. For each new friend a new row...I want to show the 5 last pictures of the friends of one user (user_1)so I try \[code\]SELECT p.picture_id, p.datetimeFROM pictures AS pWHERE p.username = ( SELECT f.user_2 FROM friends AS f WHERE f.user_1 = '(ENTER USERNAME HERE)' ORDER BY f.datetime DESC LIMIT 5)ORDER BY p.datetime DESC;\[/code\]And as you can see, the subquery return more than one row so... I need your help or suggestions to help me managing this solution!
 
Back
Top