guanxf

          我的博客:http://blog.sina.com.cn/17learning

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            71 隨筆 :: 1 文章 :: 41 評論 :: 0 Trackbacks
          LEFT JOIN 關鍵字語法:
          SELECT column_name(s) 
          FROM table_name1
          LEFT JOIN
          table_name2
          ON
          table_name1.column_name=table_name2.column_name

          高級應用:
          SELECT  	
          had.deptTypeId as deptTypeId
          ,hdt.typeName as deptTypeName
          ,had.id as deptID
          ,had.deptName as deptName
          ,isnull(sg.siteGoalPoint,0) as siteGoalPoint
          ,isnull(sg.supGoalPoint,0) as supGoalPoint
          from
          --單位
          (select a.deptTypeId,a.id,a.deptName
          from HD_ACT_DEPT a
          where 1 = 1
          and deptTypeId = 'null'
          ) as had
          LEFT JOIN
          --單位類型
          HD_DEPT_TYPE hdt
          ON had.deptTypeId = hdt.id
          LEFT JOIN
          --任務完成情況統計表
          (select a.siteGoalPoint,a.supGoalPoint,a.deptTypeId,a.deptID
          from cms_sup_submit_goal a
          where a.year = '2013'
          ) as sg
          on had.deptTypeId = sg.deptTypeId and had.id = sg.deptID
          ORDER BY had.deptTypeId, had.id
          多表查詢:
          select s.id,s.name,s.sname from 
          singer s, tb_su su
          where s.id=su.sid  and  su.userid='1'
          posted on 2013-03-28 23:41 管先飛 閱讀(455) 評論(0)  編輯  收藏 所屬分類: Database
          主站蜘蛛池模板: 漾濞| 彭泽县| 石台县| 饶河县| 钟山县| 东兴市| 磐石市| 安康市| 应用必备| 舟曲县| 安陆市| 肃北| 安多县| 宽甸| 扬州市| 麻栗坡县| 高台县| 沾化县| 靖西县| 三门峡市| 西和县| 治多县| 老河口市| 化州市| 东明县| 西丰县| 大港区| 崇左市| 昆山市| 和顺县| 邻水| 东光县| 合水县| 瑞昌市| 巴林左旗| 和田县| 梅河口市| 阿图什市| 漳浦县| 岗巴县| 南郑县|