+----+------------+
| id | text |
+----+------------+
| 33 | name1 |
| 34 | name2 |
| 35 | name3 |
| 36 | name4 |
+----+------------+
表格订单:
+----+--------+------------+----------+
| id | cid | ordername | colors |
+----+--------+------------+----------+
| 8 | 34 | name | 5 |
+----+--------+------------+----------+
一个查询是否可以得到这个结果?
+----+--------+------------+----------+
| id | cid | ordername | colors |
+----+--------+------------+----------+
| 8 | name1 | name | 5 |
+----+--------+------------+----------+
答案 0 :(得分:3)
这里你怎么做呢
select o.`id`, `text` as cid , `ordername`, `colors` from orders o
inner join customers c
on c.id = o.cid
输出:
ID CID ORDERNAME COLORS
8 name2 name 5