Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 使用查询确定表之间的关系_Sql_Relational Database - Fatal编程技术网

Sql 使用查询确定表之间的关系

Sql 使用查询确定表之间的关系,sql,relational-database,Sql,Relational Database,我想知道是否有一种方法可以通过查询来确定表之间的父子关系 select... from table1 where oid in ( select oid from table2 where mid = ? and goid = ? and table1_number = ? ) union select 0 , oid from table2 where mid=? and goid=? and is_default=\'Y\' ) order by priority desc '; 我是

我想知道是否有一种方法可以通过查询来确定表之间的父子关系

select...
from table1
where
oid in (
select oid from table2
where mid = ? and  goid = ? and table1_number = ? )
union
select 0 , oid from table2 where mid=? and  goid=? and is_default=\'Y\'
) order by priority desc ';
我是否也能确定它是1->many 1->1还是多对多?

所有数据库都有一个,它是一系列系统控制的表,存储元数据-关于数据的数据


您还没有说明使用的是哪个数据库,每个表都有自己的方法,但其中一个表将包含有关数据库中外键约束的数据。您可以查询该表,并根据需要与其他目录表合并,以获得所需的内容。

我认为问题不是很清楚,扩展它一点可能会很好。我使用的是sql。谢谢波西米亚人