I'm trying to select rows with field timestamp, which has a length shorter than 16 characters. I've tried the following:
SELECT LENGTH(timestamp), id
FROM my_table
HAVING LENGTH(timestamp) < 16
But I get this error:
#1054 - Unknown column 'timestamp' in 'having clause'
Any suggestions?
I think you want:
SELECT LENGTH(`timestamp`), id
FROM my_table
WHERE LENGTH(`timestamp`) < 16
Or if you're actually trying to group the results...
SELECT LENGTH(`timestamp`)
FROM my_table
GROUP BY LENGTH(`timestamp`)
HAVING LENGTH(`timestamp`) < 16
Note the backticks (`) in each example to escape the column name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With