'how can we check if a column exists on Table in MySQL without using Stored Procedure

how we can check if a column exists on Table in MySQL without using Stored Procedure. MySQL v3.23 which won't support writing Store Procedure.



Solution 1:[1]

v3.23 ?? If You know the table name and column name then try describe tablename or show create tablename if you know only column name select * from information schema.columns where column_name = columnname. Show tables should show all tables then manually select column name from the listed tables.

But this version is so ancient I have no idea if any of these will work

Solution 2:[2]

Try this, counting the columns in your table using the information_schema.COLUMNS.

SELECT COUNT(*) FROM information_schema.`COLUMNS` 
WHERE table_schema = 'your_database_name' 
AND table_name='your_table_name' 
AND column_name='your_column_name';

The INFORMATION_SCHEMA COLUMNS Tabletable provides information about columns in tables.

Link

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2