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 |
| 4 | edit | NULL |
| 5 | rowdata | div |
+----+----------+------+
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?
EDIT
Sorry, i forgot thats my main problem is this:
select *
from `titles_and_tags`
WHERE `title` LIKE "title%"
AND `tag` = "tag1" OR `tag` LIKE '%'
So this more like an off-topic, sorry