2015-04-06 62 views
1

我需要你的幫助。
我有這個疑問:與衆不同

SELECT t1.hotel_name 
    , t2.address 
    , t1.city 
    , t1.url AS url1 
    , t2.photo 
    , t1.partnername AS partnername1 
    , t1.maxrate AS maxrate1 
    , t1.minrate AS minrate1 
    , t2.partnername AS partnername2 
    , t2.url AS url2 
    , t2.maxrate AS maxrate2 
    , t2.minrate AS minrate2 
    , t3.partnername AS partnername3 
    , t3.url AS url3 
    , t3.maxrate AS maxrate3 
    , t3.minrate AS minrate3 
    , t4.partnername AS partnername4 
    , t4.url AS url4 
    , t4.maxrate AS maxrate4 
    , t4.minrate AS minrate4 
FROM table1 AS t1 
LEFT JOIN table2 AS t2 ON t1.hotel_name=t2.hotel_name 
LEFT JOIN table3 AS t3 ON t1.hotel_name=t3.hotel_name 
LEFT JOIN table4 AS t4 ON t1.hotel_name=t4.hotel_name 
WHERE t1.city = 'London' 
LIMIT 20; 

我需要查詢沒有返回重複的數據。
一行,一個名字。

+0

不同? – 2015-04-06 07:37:04

+0

你不想重複哪一列? – 2015-04-06 07:37:07

回答

0

您可以通過子句中使用組:依據是什麼

SELECT t1.hotel_name, t2.address, t1.city, t1.url AS url1, t2.photo, 
t1.partnername AS partnername1, t1.maxrate AS maxrate1, 
t1.minrate AS minrate1, t2.partnername AS partnername2, 
t2.url AS url2, t2.maxrate AS maxrate2, t2.minrate AS minrate2, 
t3.partnername AS partnername3, t3.url AS url3, t3.maxrate AS maxrate3, 
t3.minrate AS minrate3, t4.partnername AS partnername4, t4.url AS url4, 
t4.maxrate AS maxrate4, t4.minrate AS minrate4 FROM table1 AS t1 
LEFT JOIN table2 AS t2 ON t1.hotel_name=t2.hotel_name 
LEFT JOIN table3 AS t3 ON t1.hotel_name=t3.hotel_name 
LEFT JOIN table4 AS t4 ON t1.hotel_name=t4.hotel_name 
WHERE t1.city = 'London' 
group by t1.hotel_name,t2.address 
LIMIT 20; 
+0

hotel_name列 – 2015-04-06 08:24:27