Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Sql query to return column name, data type, data length, if a column is null

I have the following query:

SELECT column_name,
   data_type
   date_length
FROM   information_schema.columns
WHERE  table_schema = ’bookidz_ro_dev’
AND    table_name = ’rack_level’;

And I get this error: #1054 – Unknown column ‘’bookidz_ro_dev’’ in ‘where clause’
even though the db name is correct and so is the table name.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

As i tested your code is good, but those ’ quotations are not correct.

SELECT 
*
FROM   INFORMATION_SCHEMA.COLUMNS
WHERE  TABLE_SCHEMA = 'bookidz_ro_dev'
AND    TABLE_NAME = 'rack_level';

I used * because there is no Date_Length column in information_schema.columns

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading