MySQL Forums
Forum List  »  Newbie

Re: logical OR on two fields in a table in a database
Posted by: Jay Pipes
Date: June 27, 2005 12:34PM

SELECT Username, Email
FROM YourTable
WHERE Username = '$user'
UNION
SELECT Username, Email
FROM YourTable
WHERE Email = '$email'

will allow both indexes to be utilized.

Jay Pipes
Community Relations Manager, North America, MySQL Inc.

Got Cluster? http://www.mysql.com/cluster
Personal: http://jpipes.com

Options: ReplyQuote




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.