In the work of writing the first query statement of life, although the original based on the change, but still learned a lot of knowledge
Code:
SELECT DISTINCT M.id, (select Z.jianc from MODEL_ZUZJG z where z.id=m.huoz_id) as Huoz, (select MINGC from Model_pinz where id=m.meiz_id) as Meiz,ifnull ((select Kc.shul from Yw_kuczt KC where kc.meiduo_id=m.id), 0) as Shul, M.duom,ll.longitude,ll.latitude, Ifnull (Sele CT Mb.shouc_beiz from model_tongd_bzxx MB where mb.tongd_id=m.tongd_id and mb.huoz_id=m.huoz_id and mb.meiz_id=m.meiz_id and mb.user_id= ' 1 ') as Shouc_beiz,ifnull ((select Mb.shouc_status from model_tongd_bzxx MB where MB.TONGD_ID=M.TONGD _id and mb.huoz_id=m.huoz_id and mb.meiz_id=m.meiz_id and mb.user_id= ' 1 '), 0) as Shouc_status, m.huoz_id, M.meiz_idfrom mo Del_meidxx m INNER JOIN (select T.ID,T.DAIM,T.TONGDMC from Model_tongd T, (select Daim from Model_jicss where (shangjdm= ' GXTSG ' OR daim= ' GXTSG ') and fenl= ' B ') J where T.suosjcss=j.daim) TD on M.tongd_id=td.id INNER JOIN (select L.duo_id,l. Longitude,l.latitude from MoDEl_meid_lbxx L Group by l.duo_id) ll on M.id=ll.duo_idwhere m.state=1
Interpretation (Memo):
1. A subquery can be added as a temporary parameter to any stage in the select from where
2.as can temporarily assign a table alias or table name alias to write
3.ifnull ((), ') when the data being found does not exist as NULL, a different value can be assigned
4.distinct to re-fetch once
Other: MODEL_MEIDXX is the primary table, where all the data comes from whatever tables need to be associated with them, and where in the end represents the core query criteria.
SQL query statement resolution encountered in---work of personal work record