开发者

MySQL: information_schema.columns bugs?

开发者 https://www.devze.com 2023-02-20 07:45 出处:网络
Why information_schema.columns always duplicates th开发者_JAVA技巧e result? For instance, SELECT column_name

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:

MySQL: information_schema.columns bugs?


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'
0

精彩评论

暂无评论...
验证码 换一张
取 消