Reputation: 1
I have the table name test_comments
with 4 fields:
id
comments
guests
user
I want to fetch only the column heading comments and guests of this table
I had used show columns from <tablename>
but it fetched all the column headings
is there any solution for this?
Upvotes: 0
Views: 59
Reputation: 767
You can use a solution like this:
SELECT COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME LIKE 'test_comments' AND ORDINAL_POSITION IN(2,3);
The ordinal position of the column in the table. The first column in the table is number 1. you need to fetch only the column heading comments and guests of this table so use ORDINAL_POSITION IN(2,3)
Upvotes: 2