MySQL Forums
Forum List  »  General

Re: SELECT statement with multiple WHERE conditions
Posted by: Rick James
Date: September 03, 2016 05:21PM

SELECT FieldValue WHERE (FieldName = "username") (WHERE (FieldName = "email") AND (FieldValue = " $user->email"))

SELECT m.*,
a1.value AS UserName,
a2.value AS EMail
...
FROM main_table m.id
JOIN attributes a1 ON a1.entity_id = m.id AND a1.fieldname = 'username'
JOIN attributes a2 ON a2.entity_id = m.id AND a2.fieldname = 'email'
...
WHERE ...

Or...

SELECT m.*,
( SELECT value FROM attributes WHERE entity_id = m.id AND fieldname = 'username' ) AS UserName,
( SELECT value FROM attributes WHERE entity_id = m.id AND fieldname = 'email' ) AS Email,
FROM main_table m.id
WHERE ...

Options: ReplyQuote


Subject
Written By
Posted
Re: SELECT statement with multiple WHERE conditions
September 03, 2016 05:21PM


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.