ON 是语法的一部分 [英] ON is part of syntax

查看:60
本文介绍了ON 是语法的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在不指定条件的情况下编写内连接或外连接?ON 条件 是连接条件语法的一部分吗?

Is it possible to write inner join or outer join without specfying the condition? Is ON condition is part of the syntax of join condition?

推荐答案

当使用 ANSI SQL-92 语法时,ON 关键字是连接的一部分,除了cross join 因为您没有关系的条件.

when using the ANSI SQL-92 syntax, the ON keyword is part of the join except for the cross join since you don't have a condition for the relationship.

例如

内连接

SELECT *
FROM tableA INNER JOIN tableB
       on tableA.ID = tableB.ID

交叉连接

SELECT *
FROM tableA CROSS JOIN tableB

ON 应该跟在连接表之后(像INNER 和 OUTER 这样的连接),这样你就不会出现语法错误.但如果您使用 ANSI SQL-89 语法,则省略 ON 关键字,但您必须在 where 子句

ON should be followed after the joined table (joins like INNER and OUTER) so you won't have syntax error. but if you're using the ANSI SQL-89 syntax, ON keyword is omitted but you have to specify the relationship on the where clause

例如

内连接

SELECT *
FROM tableA, tableB
WHERE tableA.ID = tableB.ID

交叉连接

SELECT *
FROM tableA, tableB

它很容易出错,因为如果你忘记了条件,它不会产生语法错误并且很可能会做cross join

it is prone to error because if you forget the condition, it won't generate syntax error and will likely do the cross join

这篇关于ON 是语法的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆