我目前正在尝试查询仅为数量少于40的个人显示Num,Surname,ID和Mod。我的主要问题是将这些字段连接在一起,因为这些字段分为2个表和连接Num&的方法。姓氏和身份证的姓氏Mod需要通过另一个表来链接Num& ID。
这是我的表格
T1
+-----+-----+--------+
| Num | ID | amount |
+-----+-----+--------+
| 001 | PC3 | 44 |
| 002 | PC4 | 98 |
| 004 | PC4 | 56 |
+-----+-----+--------+
T2
+-----+---------+
| Num | Surname |
+-----+---------+
| 001 | Balls |
| 002 | Martin |
| 004 | Grey |
+-----+---------+
T3
+-----+------+
| ID | Mod |
+-----+------+
| PC3 | HTML |
| PC4 | PHP |
| PC5 | CSS |
+-----+------+
我正在思考
的内容SELECT t2.Num, t2.Surname, t3.ID, t3.Mod
FROM t2
INNER JOIN t1 ON t1.Num = t2.Num
INNER JOIN t3 ON t3.ID = t1.ID
WHERE t1.amount = <40;
答案 0 :(得分:0)
删除t1.amount和它将起作用的数值之间的'='
SELECT t1.Num, t2.Surname, t1.ID, t3.Mod
FROM t2
INNER JOIN t1 ON t1.Num = t2.Num
INNER JOIN t3 ON t3.ID = t1.ID
WHERE t1.amount < 40