MySQL: information_schema.columns bugs?
Why information_schema.columns
always duplicates th开发者_JAVA技巧e 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:
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'
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'
精彩评论