我坚持使用mysql, 我需要从基于城市的几个表中获取信息,如下所示:
table1: users contains id, name, city.
table2: users_products contains id, user_id, type.
我想根据城市检索id,city,name,product_id,product_type。 请帮帮我。
答案 0 :(得分:0)
select t1.id, t1.city, t1.name, t2.product_id from users t1, products t2
where city = "City Name";
答案 1 :(得分:0)
SELECT u.*, up.id AS ProductID, up.type
FROM users_products AS up
JOIN users AS u
ON u.id = up.user_id
WHERE u.city = "City"