I have a few tables in a database using MySQL (The engine is MyISAM). I am trying to find the lengths of the longest strings in each column (all of the data is text). Right now I am trying to run code that looks like:
SELECT LENGTH(col) FROM schema.table ORDER BY LENGTH(col) DESC LIMIT 1;
I have been manually typing in the column names and table names. However, continuing this will take forever.
At the very least, is there a way for me to assign a variable and replace the two instances of
col with that variable so I don't have to type it repeatedly?
It would be even better if I could, for a given table, iterate over all the columns and get back the length of the longest string in each column.
EDIT: Hybridzz, neither of those two links solves my problem; I can't seem to get MySQL to accept a variable assignment.
I also tried these four searches beforehand: MySQL: Assign column value to variable