MySQL Forums
Forum List  »  Knowledge Base

Strange MySQL behavior, or not?
Posted by: Eric B
Date: January 04, 2008 08:12AM

I don't believe I've ever had the occasion to come across the behavior in the third query before. Is this normal? Is MySQL essentially trying to evaluate the integer value of the field if the query doesn't include quotes around the zero?

mysql> DESC listing_elective;
+------------+--------------+------+-----+---------+-------+
| Field      | Type         | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+-------+
| listing_id | int(11)      | NO   | PRI |         |       |
| elective   | varchar(20)  | NO   | PRI |         |       |
| value      | varchar(100) | NO   |     |         |       |
+------------+--------------+------+-----+---------+-------+
3 rows in set (0.00 sec)

mysql> SELECT * FROM listing_elective;
+------------+----------------+--------------+
| listing_id | elective       | value        |
+------------+----------------+--------------+
| 21         | contact_name   | Earl Jones   |
| 26         | employees      | 65           |
...
| 31         | employees      | 12           |
| 31         | contact_value  | 800-555-1212 |
+------------+----------------+--------------+
59 rows in set (0.01 sec)

mysql> SELECT * FROM listing_elective WHERE `value` IN (0);
+------------+--------------+--------------+
| listing_id | elective     | value        |
+------------+--------------+--------------+
| 21         | contact_name | Earl Jones   |
+------------+--------------+--------------+
1 rows in set (0.01 sec)



Options: ReplyQuote


Subject
Views
Written By
Posted
Strange MySQL behavior, or not?
3138
January 04, 2008 08:12AM


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.