所以我正在学习数据库编程中使用mysql的代数关系。所以我们假设我们有这些表:
Supermarket (Shop_no, shop_name, location, manager_number)
Manager (manager_number, manager_name, salary)
我需要获得店铺经理赚取20,000美元或以上的所有商店的店铺名称和位置。所以要做到这一点,我会做这样的事情:
Select manager where salary ≥ $20,000 giving T1
Join T1, Supermarket over manager_no giving T2
Project T2 over shop_name, location giving result
所以我的问题是,这在纸面上都很好,但是我将如何在mysql中执行此操作?我试图在MYSQL上做同样的事情,但我一直收到错误:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'T1' at line 1
这意味着要么mysql做一些不同的事情来获得相同的结果,要么我做错了。
答案 0 :(得分:0)
试试这种方式
SELECT shop_name, location FROM Supermarket s INNER JOIN
Manager m ON s.manager_number=m.manager_number WHERE m.salary ≥ 20,000