Reputation: 57216
Why information_schema.columns
always duplicates the result? For instance,
SELECT column_name
FROM information_schema.columns
WHERE table_name = 'root_blocks'
I will get this,
column_name
blc_id
blc_email
cat_id
blc_created
blc_updated
blc_id
blc_email
cat_id
blc_created
blc_updated
The duplicates go unpredictable on other tables when I try to query through phpmyadmin.
How can I make it not to duplicate?
Thanks.
EDIT:
Upvotes: 1
Views: 2298
Reputation: 1091
SELECT column_name
FROM information_schema.columns
WHERE table_name = 'root_blocks'
AND `table_schema` = 'SCHEMA_NAME'
Please try this.
If you would like to select from all the database and get the unique column names then please try this..
SELECT DISTINCT(column_name)
FROM information_schema.columns
WHERE table_name = 'root_blocks'
Upvotes: 4
Reputation:
Maybe you have the same table in multiple schemas?
What happens if you run:
SELECT table_schema, column_name
FROM information_schema.columns
WHERE table_name = 'root_blocks'
Upvotes: 2