-1
我有一個場地和服務表。我想在兩次表格中選擇所有記錄。兩者都有不同的列。從兩個不相關的表格一起獲取記錄
服務表:
Name Type Collation Attributes Null Default Extra Action
1 serviceId Primary int(11) No None AUTO_INCREMENT Change
2 entry_by varchar(255) latin1_swedish_ci No None
3 service_name varchar(255) latin1_swedish_ci No None
4 service_address varchar(255) latin1_swedish_ci No None
5 latitude double No None Change Change Drop Drop
6 longitude double No None Change Change Drop Drop
7 servicetypeId int(11) No None Change Change Drop
8 active int(11) No None Change Change Drop Drop
場地表:
1 venueIdPrimary int(11) No None AUTO_INCREMENT Change
2 venue_name varchar(255) latin1_swedish_ci No None
3 venuetypeId int(11) No None Change Change Drop Drop
4 entry_by varchar(255) latin1_swedish_ci No None
5 venue_address varchar(255) latin1_swedish_ci No None
6 latitude double No None Change Change Drop Drop
7 longitude double No None Change Change Drop Drop
8 active int(11)
我嘗試此查詢:SELECT服務。 ,場地。 FROM services
,venues
但它給出重複記錄。所有記錄3次:
1
Abc
DJ siddhi
nasik
1211
4545
1
1
1
Halll siddhi
1
Abc
nasik
19.975409
73.841321
1
2
sid17
siddhi cateror
Unnamed Road, Democratic Republic of the Congo
0
0
6
1
1
Halll siddhi
1
Abc
nasik
19.975409
73.841321
1
3
sid17
flowerist
Unnamed Road, Democratic Republic of the Congo
-10.4212157
28.6031842
6
1
1
Halll siddhi
1
Abc
nasik
19.975409
73.841321
1
1
Abc
DJ siddhi
nasik
1211
4545
1
1
2
decorator siddhi
2
Abc
nasik
19.974781
73.854094
1
2
sid17
siddhi cateror
Unnamed Road, Democratic Republic of the Congo
0
0
6
1
2
decorator siddhi
2
Abc
nasik
19.974781
73.854094
1
3
sid17
flowerist
Unnamed Road, Democratic Republic of the Congo
-10.4212157
28.6031842
6
1
2
decorator siddhi
2
Abc
nasik
19.974781
73.854094
1
1
Abc
DJ siddhi
nasik
1211
4545
1
1
3
siddhi hall
8
sid17
nasik
19.995005
73.841308
1
2
sid17
siddhi cateror
Unnamed Road, Democratic Republic of the Congo
0
0
6
1
3
siddhi hall
8
sid17
nasik
19.995005
73.841308
1
3
sid17
flowerist
Unnamed Road, Democratic Republic of the Congo
-10.4212157
28.6031842
6
1
3
siddhi hall
8
sid17
nasik
19.995005
73.841308
1
1
Abc
DJ siddhi
nasik
1211
4545
1
1
4
siddhi hall
8
sid17
Sankuru, Democratic Republic of the Congo
-2.8437453
23.3823545
1
2
sid17
siddhi cateror
Unnamed Road, Democratic Republic of the Congo
0
0
6
1
4
siddhi hall
8
sid17
Sankuru, Democratic Republic of the Congo
-2.8437453
23.3823545
1
3
sid17
flowerist
Unnamed Road, Democratic Republic of the Congo
-10.4212157
28.6031842
6
1
4
siddhi hall
8
sid17
Sankuru, Democratic Republic of the Congo
-2.8437453
23.3823545
1
1
Abc
DJ siddhi
nasik
1211
4545
1
1
5
siddhi cafe
8
sid17
Unnamed Road, Democratic Republic of the Congo
0
0
1
2
sid17
siddhi cateror
Unnamed Road, Democratic Republic of the Congo
0
0
6
1
5
siddhi cafe
8
sid17
Unnamed Road, Democratic Republic of the Congo
0
0
1
3
sid17
flowerist
Unnamed Road, Democratic Republic of the Congo
-10.4212157
28.6031842
6
1
5
siddhi cafe
8
sid17
Unnamed Road, Democratic Republic of the Congo
0
0
1
1
Abc
DJ siddhi
nasik
1211
4545
1
1
6
siddhi cafe
8
sid17
Lomami, Democratic Republic of the Congo
-1.899681
22.72851
1
2
sid17
siddhi cateror
Unnamed Road, Democratic Republic of the Congo
0
0
6
1
6
siddhi cafe
8
sid17
Lomami, Democratic Republic of the Congo
-1.899681
22.72851
1
3
sid17
flowerist
Unnamed Road, Democratic Republic of the Congo
-10.4212157
28.6031842
6
1
6
siddhi cafe
8
sid17
Lomami, Democratic Republic of the Congo
-1.899681
22.72851
1
1
Abc
DJ siddhi
nasik
1211
4545
1
1
7
green lawn
8
sid17
N5, Democratic Republic of the Congo
-10.4212157
28.6031842
1
2
sid17
siddhi cateror
Unnamed Road, Democratic Republic of the Congo
0
0
6
1
7
green lawn
8
sid17
N5, Democratic Republic of the Congo
-10.4212157
28.6031842
1
3
sid17
flowerist
Unnamed Road, Democratic Republic of the Congo
-10.4212157
28.6031842
6
1
7
green lawn
8
sid17
N5, Democratic Republic of the Congo
-10.4212157
28.6031842
1
1
Abc
DJ siddhi
nasik
1211
4545
1
1
8
hotel nashik
8
sid17
Mai-Ndombe, Democratic Republic of the Congo
-2.6357434
18.4276047
1
2
sid17
siddhi cateror
Unnamed Road, Democratic Republic of the Congo
0
0
6
1
8
hotel nashik
8
sid17
Mai-Ndombe, Democratic Republic of the Congo
-2.6357434
18.4276047
1
3
sid17
flowerist
Unnamed Road, Democratic Republic of the Congo
-10.4212157
28.6031842
6
1
8
hotel nashik
8
sid17
Mai-Ndombe, Democratic Republic of the Congo
-2.6357434
18.4276047
1
如何從兩個表中獲得唯一記錄?謝謝。
什麼是你想要的表格中顯示的預期結果? – Drew
在查詢中嘗試使用DISTINCT關鍵字。 – FDavidov
這兩個表都沒有任何關係,使用「select * from table a union select * from table b」 –