Why does query 1 not return the same items as query 2? Effectively, it works the same as query 4.
MySQL Server version: 5.1.73-log Source distribution
mysql client Ver 14.14 Distrib 5.7.22, for Linux (x86_64) using EditLine wrapper
mysql> desc eprint;
+---------------------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------------------+---------------------+------+-----+---------+-------+
| eprintid | int(11) | NO | PRI | NULL | |
...
| abstract_nicht_anzeigen | set('TRUE','FALSE') | YES | | NULL | |
mysql> select count(*),abstract_nicht_anzeigen from eprint group by abstract_nicht_anzeigen; +----------+-------------------------+
| count(*) | abstract_nicht_anzeigen |
+----------+-------------------------+
| 19766 | NULL |
| 32177 | |
| 736 | TRUE |
+----------+-------------------------+
3 rows in set (0.23 sec)
SELECT eprintid,ac_nummer,urn,thesis_type
FROM eprint
WHERE eprint_status="archive" and metadata_visibility="show" and date_sperre_year is null
and einverstaendnis=TRUE and full_text_status="public"
and abstract_nicht_anzeigen<>TRUE and urn is not null;
...
19544 rows in set (0.29 sec)
SELECT eprintid,ac_nummer,urn,thesis_type
FROM eprint
WHERE eprint_status="archive" and metadata_visibility="show" and date_sperre_year is null
and einverstaendnis=TRUE and full_text_status="public"
and (abstract_nicht_anzeigen is NULL or abstract_nicht_anzeigen="") and urn is not null;
...
32651 rows in set (0.02 sec)
SELECT eprintid,ac_nummer,urn,thesis_type
FROM eprint
WHERE eprint_status="archive" and metadata_visibility="show" and date_sperre_year is null
and einverstaendnis=TRUE and full_text_status="public"
and abstract_nicht_anzeigen is NULL and urn is not null;
...
13107 rows in set (0.30 sec)
SELECT eprintid,ac_nummer,urn,thesis_type
FROM eprint
WHERE eprint_status="archive" and metadata_visibility="show" and date_sperre_year is null
and einverstaendnis=TRUE and full_text_status="public"
and abstract_nicht_anzeigen="" and urn is not null;
...
19544 rows in set (0.29 sec)
Ok, I figured it out.
abstract_nicht_anzeigen<>TRUE
only operrates on those rows where this column actually has a value."TRUE"
in the set definition. This is a lucky conincidence. If the column was declared asset ('FALSE', 'TRUE')
it would select those rows where the value is"FALSE"
.enum('TRUE','FALSE')
. This accident allows for rows to have the value ``"TRUE, FALSE"` which does not make sense."TRUE"
and alls possible values ofabstract_nicht_anzeigen
excluding"TRUE"
):