I am enrolled at the Art Institute of Pittsburgh - Online working towards a Bachelor of Science in photography.
My other blog [blogspot.com]
A coworker just showed me a MySQL query that gave him a pretty good scare yesterday.
mysql> SELECT COUNT(*) MISSION_CRITICAL_TABLE;
+------------------------+
| MISSION_CRITICAL_TABLE |
+------------------------+
| 0 |
+------------------------+
1 row in set (0.00 sec)
I did a double take when he showed it to me because I too missed the typo at first. That is a valid MySQL statement that means show me the count of nothing and call it MISSION_CRITICAL_TABLE. You see the 'AS' is optional. What he intended to type was:
mysql> SELECT COUNT(*) FROM MISSION_CRITICAL_TABLE;
+----------+
| COUNT(*) |
+----------+
| 7030295 |
+----------+
1 row in set (0.00 sec)
Okay, you can stop laughing at us now. I just thought that this was something that everyone who uses MySQL should be aware of.
My first big $job screw-up was an SQL typo/thinko (Score:1)
Some ten years ago I an 'UPDATE PRODUCTION_TABLE SET FOO = "BAR"' query to "correct" a mistake that someone else had made. Notice the lack of the WHERE clause ;-) Needless to say I haven't run an UPDATE without first running its SELECT counterpart since.
-- Douglas HunterWow (Score:2)
I will never complain about having to add "FROM DUAL" in Oracle again!
J. David works really hard, has a passion for writing good software, and knows many of the world's best Perl programmers