MySQL Forums
Forum List  »  Newbie

Re: Complicated Query
Posted by: Keith Larson
Date: June 06, 2013 08:55PM

> SELECT U1.`Value` AS "First Name" , U2.`Value` AS "Last Name" , U3.`Value` AS Age , R. Registered
-> FROM `Users` U1
-> LEFT JOIN `Users` U2 ON U1.UserID = U2.UserID AND U2.FieldID = 2
-> LEFT JOIN `Users` U3 ON U1.UserID = U3.UserID AND U3.FieldID = 3
-> LEFT JOIN Registrations R ON R.UserID = U1.UserID
-> WHERE U1.FieldID = 1
-> GROUP BY U1.UserID;
+------------+-----------+------+------------+
| First Name | Last Name | Age | Registered |
+------------+-----------+------+------------+
| John | Harris | 30 | Yes |
| Amy | Ford | 35 | No |
+------------+-----------+------+------------+
2 rows in set (0.00 sec)

Just trying to help....

http://anothermysqldba.blogspot.com

Options: ReplyQuote


Subject
Written By
Posted
June 06, 2013 07:44PM
June 06, 2013 08:29PM
Re: Complicated Query
June 06, 2013 08:55PM
June 07, 2013 06:02AM
June 07, 2013 03:12PM
June 08, 2013 06:01AM
June 08, 2013 09:47AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.