MySQL Forums
Forum List  »  Newbie

Re: logical OR on two fields in a table in a database
Posted by: Erin ONeill
Date: June 27, 2005 12:50PM

hmm that didn't help at all. Here are the two explains (for the original with the OR and for the UNION select) These were done on the dev box and not the production box:

mysql> explain SELECT Username,Email,U_Number from Users WHERE Username = 'someuser@example.com' OR Email = 'someuser@example.com';
+-----------+------+------------------+------+---------+------+-------+-------------+
| table | type | possible_keys | key | key_len | ref | rows | Extra |
+-----------+------+------------------+------+---------+------+-------+-------------+
| Users | ALL | Username,indx1 | NULL | NULL | NULL | 44857 | Using where |
+-----------+------+------------------+------+---------+------+-------+-------------+
1 row in set (0.00 sec)


mysql> explain SELECT Username,Email,U_Number from Users WHERE Username = 'someUser@example.com' UNION
-> SELECT Username,Email,U_Number from Users WHERE Email = 'someUser@example.com' ;
-----------+------+---------------+------+---------+------+-------+-----------------------------------------------------+
| table | type | possible_keys | key | key_len | ref | rows | Extra |
+-----------+------+---------------+------+---------+------+-------+-----------------------------------------------------+
| | | | | 0 | | 0 | Impossible WHERE noticed after reading const tables |
| Users | ALL | NULL | NULL | NULL | NULL | 44857 | Using where |
+-----------+------+---------------+------+---------+------+-------+-----------------------------------------------------+
2 rows in set (0.58 sec)

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.