从比较两个表mysql获取记录

时间:2016-10-12 07:20:26

标签: mysql

表1

id   |  sub_location  | admin_location 
CUS1 | Valasaravakkam | Tamil Nadu
CUS1 | Alwartirunagar | Chennai
CUS2 | KK Nagar       | Tamil Nadu  
CUS3 | Valasaravakkam | Tamil Nadu  
CUS3 | KK Nagar       | Tamil Nadu  
CUS3 | Alwartirunagar | Chennai

表2

id  |  sub_location  | admin_location 
c1  | Porur          | Tamil Nadu
c1  | West Mambalam  | Chennai
c1  | Ashok Nagar    | Tamil Nadu   
c3  | Ramapuram      | Tamil Nadu   
c3  | Nungambakkam   | Tamil Nadu   
c3  | Meenambakkam   | Chennai

获取任何一个匹配的sub_location表1和表2以及表1和表2中任何一个匹配的admin_location的id

1 个答案:

答案 0 :(得分:0)

获取哪个表table1或table2的ID?