Weak data typing in MySQL

MySQL is a great product and mature, but sometimes... $SUBJ.

So I have a table TABLE with VARCHAR column/field COLUMN.

I can run: SELECT * from TABLE where LENGTH(COLUMN<10);

This executed, but I got all possible records, with all possible lengths of COLUMN. WTF? Ouch, I've been experienced lack of sleep :(

I should have written it as: SELECT * from TABLE where LENGTH(COLUMN)<10; That works correctly.

I'm not a DB/RDBMS/SQL/PL expert. But in my opinion, MySQL should return a (syntax) error in first case? That would be better, IMHO.

(the post first published at 20230126.)

List of my other blog posts.

Subscribe to my news feed

Yes, I know about these lousy Disqus ads. Please use adblocker. I would consider to subscribe to 'pro' version of Disqus if the signal/noise ratio in comments would be good enough.