karimali831 Posted June 9, 2010 Share Posted June 9, 2010 Hello, With this query, I assume it checks if there are no cup table? if(!mysql_num_rows(mysql_query("SHOW TABLES LIKE '".PREFIX."cups'"))) How can I check if a column existings within a table? So lets say I altered a table and added column "name" and I use a query to check if this column exists? Is there a query I can use for this? Thanks for help. Quote Link to comment Share on other sites More sharing options...
Mchl Posted June 9, 2010 Share Posted June 9, 2010 Run this query: SELECT COLUMN_NAME FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = 'yourDataBase' AND TABLE_NAME = 'yourTableName' AND COLUMN_NAME = 'columnYouCheckFor' and check if it returns 0 or 1 rows. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.