我想加入3张桌子:
surplused
userNo
紧急
subCategoryNo
我需要获取一组数据,其中包括由'doNo'和'lname'订购的所有设备信息,这些信息由'userNo'链接,员工'subNategoryNo'只需要来自子类别的子类别'categoryNo'等于2.
在迷路和困惑之前我已经走了这么远。
SELECT equipment.*, employees.lname, employees.fname
FROM equipment
LEFT JOIN employees
USING (userNo)
ORDER BY equipment.doNo, employees.lname;
我无法弄清楚如何将其限制为'categoryNo'2;
答案 0 :(得分:1)
SELECT equipment.*, employees.lname, employees.fname
FROM equipment
LEFT JOIN employees USING (userNo)
JOIN subcategories USING(subCategoryNo)
WHERE subcategories.categoryNo=2
ORDER BY equipment.doNo, employees.lname;