比较Oracle SQL中的两个字段的值(Comparing two fields' values in Oracle SQL)
我在Oracle中有这样的声明:
select agnt_name,
exporter_name
from
(
select agnt_name,
exporter_name
from Exporters
union all
select agnt_name,
exporter_name
from agents
)
现在如果我添加这个条件: WHERE agnt_name = exporter_name
我的问题是:查询是否会比较两个字段中的值?如果它们相等,它会显示记录吗? 或者这种情况会像加入条件一样?
I have this statement in Oracle:
select agnt_name,
exporter_name
from
(
select agnt_name,
exporter_name
from Exporters
union all
select agnt_name,
exporter_name
from agents
)
now if I add this condition: WHERE agnt_name = exporter_name
My question is: Will the query compare the values in both fields & if they equal it'll show the records? Or will this condition be like a join condition?
原文:https://stackoverflow.com/questions/33389362
更新时间:2020-02-10 12:41
最满意答案
您没有join查询 - 甚至不是隐式join 。 因此,添加条件只会比较同一行中两列中的值。
You have no join in your query -- not even an implicit join. Hence, adding the condition will just compare the values in the two columns in the same row.
2015-10-28
相关问答
在应用程序开发下面,有个SQL PLUS,可以在那里进行数据库的各种操作,比如对系统的管理、用户管理、数据的增删查改、各种对象的建立(表、视图、序列、同义词、存储过程等等),不过这个是纯文本的操作环境,对用户要求较高,也比较繁琐。 最好安装一个第三方的PL SQL工具,比如PLSQL DEVELOPER、TOAD都比较好用。这些都是图形界面,易于操作,对新手来说,绝对比ORACLE自带的SQL PLUS好用百倍,容易上手。 有问题请追问,如满意请采纳。
左外连接用left join,右外连接用right join语句。 比如 Oracle: select * from a, b where a.id=b.id(+) SQL: select * from a left join b on a.id=b.id 反过来a.id(+)=b.id 就是right join
ANY (或其同义词SOME )是具有简单相关性的EXISTS的语法糖: SELECT *
FROM mytable
WHERE x <= ANY
(
SELECT y
FROM othertable
)
是相同的: SELECT *
FROM mytable m
WHERE EXISTS
(
SELECT NULL
FROM othertabl
...
你可以使用regex_like WHERE REGEXP_LIKE (CUSTOMER_ADDRESS , '^[A-Z]');
You could use regex_like WHERE REGEXP_LIKE (CUSTOMER_ADDRESS , '^[A-Z]');
这是SQL Fiddle演示: http ://www.sqlfiddle.com/#!4/1462f7 /3 select "TABLE", "PERIOD", "COUNTRY", "CODE", "POSITION", to_char(Oct_14) Oct_14 , To_Char(Nov_14) Nov_14, To_Char(Dec_14) Dec_14 from Table1
union
select 'COMPARE', '','', NULL, '',
(select 'AT
...
解决方案的质量取决于可能的id_glo值和您可以使用的sql方言。 作为开始,试试吧 select s.id_glo
, r.id_glo
from eb_site s
inner join eb_register r on ( replace(replace(s.id_glo, 'kplus.hs.register.', ''), 'kplus.hs.dlsn.', '') <> replace(replace(r.id_glo, 'kplu
...
使用union all : select distinct task_id
from ((select task_id, assigned_id as id
from tbl_tasks
) union all
(select task_id, source_id
from tbl_resources
)
) ti
where id = ?;
请注意,如果有人被分配到两个表中的相同任务,则会使用select distinc
...
如果你想匹配这里显示的限制,你可以使用检查约束: SQL> create table foo (id number primary key,
constraint foo_uint_id check (id between 0 and 4294967295));
Table created.
SQL> insert into foo (id) values (-1);
insert into foo (id) values (-1)
*
ERROR at line 1:
ORA-0
...
如果您只关注美国,则可以通过平面文件格式获取几个邮政编码来源并将其导入到表格中,然后将地址中的外键约束应用于该表格。 可以将电子邮件地址与正则表达式(需要10g或更高)进行匹配来验证格式,但检查它们是否是实际地址是一项非常困难的任务。 If you're only concerned with the US, there are several sources of zip codes that you can obtain in flat-file format and import into
...
您没有join查询 - 甚至不是隐式join 。 因此,添加条件只会比较同一行中两列中的值。 You have no join in your query -- not even an implicit join. Hence, adding the condition will just compare the values in the two columns in the same row.