$fld_one ='SHOW COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE SCHEMA = '.$dbone'.'AND TABLE NAME = '.$tbone.'';
SHOW COLUMNS FROM $tbone FROM mydb;
Asked
Active
Viewed 194 times
-2

chris85
- 23,846
- 7
- 34
- 51

Sachin Sharma
- 9
- 6
-
I have tried both the codes but its not printing unique fields of a particular table – Sachin Sharma Dec 17 '15 at 13:02
-
you're probably looking for a SELECT syntax, but whatever it is, your question is unreadable and unprecise, and pretty obvious you didnt make any effort to look for widely known and described solutions – mikus Dec 17 '15 at 13:02
-
2Possible duplicate of [MySQL query to get column names?](http://stackoverflow.com/questions/4165195/mysql-query-to-get-column-names) – Pathik Vejani Dec 17 '15 at 13:03
-
Is that formatted correctly? Seems to be off.. maybe pseudo code? – chris85 Dec 17 '15 at 13:07
2 Answers
2
Its query gives the all column_name
SELECT group_concat(column_name)
FROM information_schema.columns
WHERE table_schema = 'DB_NAME' AND table_name = 'TABLE_NAME'

Vipin Jain
- 3,686
- 16
- 35
0
This should hopefully do what you want.
$sql="select `column_name`
from `information_schema`.`columns`
where `table_schema`=database() and `table_name`='$tbone';";

Professor Abronsius
- 33,063
- 5
- 32
- 46