在我的数据库我有这些表SQL连接和MySQL
products
-------------
id | title |
-------------
1 Cheese
2 Milk
3 Water
等.....
products_to_city
-----------------------
city_id | product_id |
-----------------------
1 1
1 2
2 3
3 1
3 1
我使用这个SQL查询来获取结果
SELECT
p.id,
p.title
FROM products p
LEFT JOIN products_to_city ptc ON ptc.id = 1
问题是,上面的查询获取表中的所有数据,而不是仅在城市为1的地方。
我在做什么错了?
要通过1〜说什么在你的查询?该id或字段号码? –