mysql - SQL 前向引用语法

标签 mysql sql sql-server syntax

我是 SQL 的新手,所以我不知道术语并且正在编造单词,但我不知道在哪里可以找到这种语法 -

选择名称 = p.e_full_Name 来自 db..port p, db..port_x il 其中 p.port_id = il.port_id 和 p.port_id = "blah"

据我推断,name 将成为 p.e_full_name 列的名称,pil 是定义的变量在 from 语句中(pdb..port 表,ildb.port_x 表)。它是否正确?这种语法叫什么,我可以在哪里阅读它?

最佳答案

SELECT columns
FROM <table> <alias>
JOIN <anotherTable> <differentAlias>
ON alias.column = differentAlias.column
WHERE alias.column = 'Blah'

在您的示例中,p 和 il 作为表的别名,以节省再次输入表名的时间。 p.port_id = il.port_id 是一个加入条件(应该是ON子句的一部分)

select name = p.e_full_Name 
from db..port p, db..port_x il 
where p.port_id = il.port_id and p.port_id = "blah"

搜索 JOIN,您会找到示例。将代码调整为第一个示例,您的示例是不应再使用的旧式 JOIN

关于mysql - SQL 前向引用语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23017300/

相关文章:

c# - SQL Server 中的数据类型二进制(1632)和 MYSQL 中的数据类型二进制(255)之间的区别?

mysql - 如何将 mysql 容器中的更改数据提交到新图像

android - 如何创建与 Room 一起使用的 sqlite View ?

c# - mySQL 从一个表中选择,从另一个表中加入,然后从新表中选择

sql - 如何使用 sql 查询 SQL Server 将 unicode 转换为德语元音变音

sql-server - SQL Server 二进制(128)从小端转换为大端

mysql - 如何在 MYSQL 中一次更新多个列?

mysql - 在日期之间选择mysql查询?

mysql - 记录 mysql 查询

sql-server - 处理 Azure SQL DB 中的错误 "External tables are not supported with the provided data source type"?