Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I return all columns in a table which contains only data with four characters or less?

Tags:

mysql

I'm mapping data from a MySQL table and have a table that has over 50 columns and over 100,000 rows, and I need to map a column that has data in it which has 4 characters or less.

How can I get a list of all columns in the table which have data that contains only four characters or less? In my case, all columns are varchar(255).

like image 341
Edward Tanguay Avatar asked Nov 13 '22 21:11

Edward Tanguay


1 Answers

SELECT
  COLUMN_NAME

FROM INFORMATION_SCHEMA.COLUMNS

WHERE TABLE_NAME = <table>
AND CHAR_LENGTH(COLUMN_NAME) <= 4
like image 142
Mark Avatar answered Nov 15 '22 13:11

Mark