I have a table in mysql contains almost 150 columns. I want to find out those column name which has no more than 3 character data. I am not finding the column whose data type length is less than 3 character.
Example
+-----------------+-----------------+-----------------+
| Col1 (varchar10)| Col2 (varchar10)| col3 (varchar11)|
+-----------------+-----------------+-----------------+
| 11 | 1212 | 1212 |
| 1 | 122 | 12 |
| 15 | 123 | 134444 |
+-----------------+-----------------+-----------------+
The result should be like
+--------------+
| Column Names |
+--------------+
| Col1 |
+--------------+
| Col3 |
+--------------+.
So for I have come across this SQL to print column names but the length is actual column data type length. I want Data length.
SELECT column_name,
character_maximum_length
FROM information_schema.columns
WHERE table_schema = 'tvs' and table_name = 'xyz'
Note: This example show varchar(10) data type but in actual I have numeric as well var char columns.