表员工:
+----+------------+
| id | firstname |
+----+------------+
| 1 | name1 |
+----+------------+
表格订单:
+----+--------+
| id | eid |
+----+--------+
| 1 | 2 |
+----+--------+
一个查询是否可以获得此结果?
+----+--------+
| id | eid |
+----+--------+
| 1 | name1 |
+----+--------+
答案 0 :(得分:1)
如果update
的数据类型为int,则无法直接执行orders.eid
。首先将其更改为sting然后执行此UPDATE
语句
UPDATE orders a
INNER JOIN employee b
ON a.id = b.id
SET a.eid = b.firstName
答案 1 :(得分:0)
我认为这就是你所要求的,但你的问题并不完全清楚。
select orders.id, employee.firstname
from orders
inner join employee on orders.eid = employee.id