MySQL: fetching a null or an empty string
- by Oden
Hey,
I know whats the difference between a NULL value and an empty string ("") value, but if I want to get a value by using the OR keyword, I get no result for a NULL value
The table i want to query looks like this:
titles_and_tags
+----+----------+------+
| id | title | tag |
+----+----------+------+
| 1 | title1 | NULL |
| 2 | title2 | tag1 |
| 3 | title3 | tag2 |
+----+----------+------+
The query i use looks like this:
select * from `titles_and_tags` WHERE `title` LIKE "title" AND `tag` = "tag1" OR `tag` IS NULL
So i want to get here a rows (id: 1,2), BUT this results 0 rows. What have i done wrong?