简体   繁体   中英

How do I know one table's primary key field value is used in any another related tables in MySQL?

How do I know one table's primary key field value (eg ID) is used in any another related tables in MySQL?

Please help me.

You have to know the structure of your database. Then you can do something like

select * from your_table where id in 
(
    select id from ref_table1
    union
    select id from ref_table2
    union
    select id from ref_table3
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM