这条SQL语句要怎么写
现有两张表
主表table1有字段id ,port1,port2,port3
参数表para字段为:port_no,port_name
我写的语句为
select
a.id,
b.Port_name as port1,
b.port_name as port2,
b.port_name as port3
from table1 as a,para as b
where a.port1=b.port_no
and a.port1=b.port_no
and a.port1=b.port_no
但是查询出来的结果不对,请问为什么?要怎么写才对呢?
主表table1有字段id ,port1,port2,port3
参数表para字段为:port_no,port_name
我写的语句为
select
a.id,
b.Port_name as port1,
b.port_name as port2,
b.port_name as port3
from table1 as a,para as b
where a.port1=b.port_no
and a.port1=b.port_no
and a.port1=b.port_no
但是查询出来的结果不对,请问为什么?要怎么写才对呢?
...全文
相关推荐
SQL数据库常用基础语句大全
比如我们要将ID为1的学生的年龄改为21,可以这么写: ```sql UPDATE students SET age = 21 WHERE id = 1; ``` 这条语句将`students`表中ID
通过Navicat 写SQL语句
具体步骤: 1、首先打开要写SQL语句的数据库连接 2、然后点击菜单中的查询(query) 3、然后点击新建查询 4、然后输入SQL语句,点击运行,查询到的数据在底部
sql常见的语句
根据提供的文件信息,我们将深入探讨SQL中的常见语句,包括删除、查询、更改和添加信息的操作,这些操作是数据库管理中最基础且关键的部分。
执行一条sql语句update多条记录实现思路
ON DUPLICATE KEY UPDATE语句,它在MySQL中特别有用。当尝试插入的记录存在主键冲突时,这条语句会更新已有记录的某些字段。
ORACLE__SQL语句教学
- **关键字不可缩写:**SQL关键字必须完整写出,不能使用缩写形式。- **各子句分行:**为了提高可读性,通常建议每个子句写在单独的一行。


