0

我在这里坚持使用mysql,我需要从几个基于城市的表中获取信息,如下所示:

table1: users contains id, name, city.
table2: users_products contains id, user_id, type.

我想根据城市检索 id、city、name、product_id、product_type。请帮我。

4

2 回答 2

0
select t1.id, t1.city, t1.name, t2.product_id from users t1, products t2
where city = "City Name";
于 2013-10-18T17:08:50.753 回答
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"
于 2013-10-18T17:09:55.003 回答