INF表层访问

时间:2016-05-05 06:14:46

标签: mysql query-optimization

如何从多个表中快速选择数据?这是一个SQL命令,但它需要花费很多时间并挂起计算机。

SELECT U1.id,U1.name,U3.gname,U2.rname,U1.day,U1.month,U1.year,U1.email,U5.country,U1.country_code,U1.number,U4.mtname,U7.mstatus,U8.state,U9.city,U10.name,U6.sub_community,U12.hname,U13.sname,U14.name,U15.name,U16.name,U17.food
 FROM userprofile1 as U1

 JOIN religion as U2
  ON U1.Relegion=U2.reid
 JOIN gender as U3
   ON U1.ugender=U3.g_id
 JOIN mother_tongue as U4
   ON U1.mother_tongue=U4.mt_id
 JOIN country as U5
   ON U1.country=U5.country_id
 JOIN  userprofile2 as U6
   ON U1.id=U6.f_id1
 JOIN maritialstatus as U7
   ON U6.maritial_status=U7.id
 JOIN state as U8
   ON U6.state=U8.state_id
 JOIN city as U9
   ON U6.city=U9.city_id
 JOIN community as U10
   ON U6.ucommunity=U10.id
 JOIN userprofile3 as U11
   ON U6.1id=U11.f_id2
 JOIN height as U12
   ON U11.uheight=U12.h_id
 JOIN skin as U13
   ON U11.uskin=U13.s_id
 JOIN smoke as U14
   ON U11.usmoke=U14.sm_id
 JOIN drink as U15
   ON U11.udrink=U15.d_id  
 JOIN body as U16
   ON U11.ubody=U16.b_id  
JOIN food as U17
   ON U11.ufood=U17.id     

0 个答案:

没有答案