Things in MySQL that won't work as expected
explainextended.com
explainextended.com
SELECT * FROM example WHERE value = 'á';
where "á" uses UTF-8 encoding.
By default this will return rows that match both "á" AND "a", which may or may not be what you want.
If you want to make MySQL distinguish between an "a" with an accent and one without, then you need to specify a collation either in the table creation/alter statement, or in your query directly:
SELECT * example WHERE value = 'á' COLLATE utf8_bin;
WHERE column IN ('1, 2, 3')
How can this ever be expected to work, unless, of course your column is literally '1, 2, 3'? Seems strange to blame MySQL for it. ("MySQL is buggy because it cannot infer meaning from my arbitrary string literals!")http://stackoverflow.com/questions/4037145/mysql-how-to-sele...
http://stackoverflow.com/questions/3946831/mysql-where-probl...
http://stackoverflow.com/questions/3734161/mysql-select-wher...
None actually "blames" MySQL for that. The article just describes what comes to the beginning developer's mind first, and tells the correct way to do that.
In Date's book "Database in Depth" he gives some wonderful examples of how NULL in SQL breaks things. One I recall involved a couple simple tables and a simple question about the data. There were something like half a dozen or so reasonable ways one might write a query to answer the question--and there were many different answers depending on the exact query.
"Database in Depth" has been updated and refocused more on SQL, and is now called "SQL and Relational Theory". He sums up in the latter book the problem with NULL thusly:
To sum up: If you have any nulls in your database, then
you’re getting wrong answers to certain of your queries.
What’s more, you have no way of knowing, in general,
just which queries you’re getting wrong answers to and
which not; all results become suspect. You can never
trust the answers you get from a database with nulls.
In my opinion, this state of affairs is a complete
showstopper.People will usually reply to my criticisms about SQL NULL by pointing out that it is logically consistent, which is true, but it's not the only logically consistent NULL we can define. I know the theory behind the SQL NULL quite well, well enough to observe just how rarely it matches SQL practice.
But yeah, if it's in a query that you're going to run on every single hit to the index page of a busy site, then you're going to have problems.