ziltech Posted November 12, 2008 Share Posted November 12, 2008 Hi, I have obtained a PHP script that uses the SHOW COLUMNS statement. The entire statement is SHOW COLUMNS from `addressbook`. The script then displays all the database column names as table rows with no formatting. This works well. However, What I would like to do is show only a few select columns. Something like this, SHOW COLUMNS from `addressbook` LIKE 'firstname', 'lastname' I've tried this and it doesn't work. Also, the output table displays the column names 'as is', but is it possible to change firstname into First Name (formatted). Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/132394-show-columns/ Share on other sites More sharing options...
JonnoTheDev Posted November 12, 2008 Share Posted November 12, 2008 You are trying to use the SHOW command in the manor of the SELECT command. This is not what it is designed for. Quote Link to comment https://forums.phpfreaks.com/topic/132394-show-columns/#findComment-688606 Share on other sites More sharing options...
fenway Posted November 12, 2008 Share Posted November 12, 2008 You could do this with the I_S tables in v5, but you'll need to clean it up in php anyway, so why not just start there/ Quote Link to comment https://forums.phpfreaks.com/topic/132394-show-columns/#findComment-688664 Share on other sites More sharing options...
corbin Posted November 12, 2008 Share Posted November 12, 2008 SHOW COLUMNS FROM addressbook WHERE Field IN ('firstname', 'lastname'); Not sure if it's proper. It works though >.<. lol Edit: MySQL 5. Might not work earlier. Quote Link to comment https://forums.phpfreaks.com/topic/132394-show-columns/#findComment-688917 Share on other sites More sharing options...
ziltech Posted November 14, 2008 Author Share Posted November 14, 2008 Hi there, Thanks for the replies - unfortunately the host is running MySQL 4.1.4 so the above queries don't work. I'll keep looking. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/132394-show-columns/#findComment-690036 Share on other sites More sharing options...
fenway Posted November 17, 2008 Share Posted November 17, 2008 unfortunately the host is running MySQL 4.1.4 so the above queries don't work. refman describes 4.1-compatible syntax as: SHOW [FULL] COLUMNS FROM tbl_name [FROM db_name] [LIKE 'pattern'] So you should be able to get it to work. Quote Link to comment https://forums.phpfreaks.com/topic/132394-show-columns/#findComment-692151 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.