Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/72.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_Oracle_Oracle Sqldeveloper - Fatal编程技术网

我想知道下面用sql编写的代码的含义

我想知道下面用sql编写的代码的含义,sql,oracle,oracle-sqldeveloper,Sql,Oracle,Oracle Sqldeveloper,一位同事使用了这个查询,我想知道内部select查询(即,从表(:input\U country\U object)中选择1)的含义。谁能给我详细解释一下它是如何工作的 Select id, country_name, price, section, population, diversity from Country co where exists ( select

一位同事使用了这个查询,我想知道内部select查询(即,从表(:input\U country\U object)中选择1)的含义。谁能给我详细解释一下它是如何工作的

Select 
       id, 
       country_name, 
       price, 
       section, 
       population, 
       diversity 
from Country co 
where exists (
               select 1 
               from table (:input_country_object) ico 
               where co.country_name = ico.country_name
              );

提前感谢。

当您在蟾蜍上运行此代码f.e.时,它会要求您编写
tablename
,而不是
:input_country_object

因此,当您编写表名时,查询会起作用


您可以从下图中看到它:

如果您只关心“内部选择”的功能,请看:

select 1 
from table (:input_country_object) ico 
where co.country_name = ico.country_name
如果满足where条件,查询基本上只选择值
1


因此,如果有此条件的数据:
其中co.country\u name=ico.country\u name
:input\u country\u object
表中,则此选择仅返回
1

这会导致查询的
exists(…)
部分返回true,因此执行查询的第一部分
从国家/地区选择id、国家/地区名称、价格、区域、人口、多样性

因此,总的来说,查询将返回以下值:

id、国家名称、价格、部门、人口、多样性

从你的

国家/地区
表格

对于也在第二个表中的所有国家


:输入\国家\对象



:input\u country\u object
本身是SQL开发人员将填写的变量,或者您必须指定的变量。

查询看起来有些虚假,因为它似乎试图使用绑定参数作为表名。耶,绑定参数Tim是什么?
:input\u country\u object
我可以知道这个内部查询是如何工作的吗?@TimBiegeleisen:我想这是一个被Oracle的SQL开发人员取代的参数