• 数据库如何连接三个表


    相对最优:

    SELECT ASSETCHANGEAPPLYINFO.*,ASSETCHANGEINFO.OPERATION

                   FROM

                        ASSETCHANGEINFO_ASSETCHANGEAPPLYINFO

                        INNER JOIN ASSETCHANGEAPPLYINFO ON ASSETCHANGEINFO_ASSETCHANGEAPPLYINFO.ASSET_CHANGE_APPLYINFO_ID = ASSETCHANGEAPPLYINFO.ID

                       LEFT JOIN ASSETCHANGEINFO ON ASSETCHANGEINFO_ASSETCHANGEAPPLYINFO.ASSET_CHANGEINFO_ID=ASSETCHANGEINFO.ID

     另外的方法:

    SELECT a.*, ASSETCHANGEINFO.OPERATION

                   FROM (

                        SELECT * FROM   ASSETCHANGEINFO_ASSETCHANGEAPPLYINFO

                        INNER JOIN ASSETCHANGEAPPLYINFO ON ASSETCHANGEINFO_ASSETCHANGEAPPLYINFO.ASSET_CHANGE_APPLYINFO_ID = ASSETCHANGEAPPLYINFO.ID) AS a

                        LEFT JOIN ASSETCHANGEINFO ON a.ASSET_CHANGEINFO_ID=ASSETCHANGEINFO.ID

     SELECT        ASSETCHANGEAPPLYINFO.*,ASSETCHANGEINFO.OPERATION

                   FROM

                        ASSETCHANGEINFO_ASSETCHANGEAPPLYINFO,ASSETCHANGEAPPLYINFO,ASSETCHANGEINFO

                       WHERE ASSETCHANGEINFO_ASSETCHANGEAPPLYINFO.ASSET_CHANGE_APPLYINFO_ID = ASSETCHANGEAPPLYINFO.ID

                       AND ASSETCHANGEINFO_ASSETCHANGEAPPLYINFO.ASSET_CHANGEINFO_ID=ASSETCHANGEINFO.ID

  • 相关阅读:
    Ubuntu 14.04 LTS 安装 NVIDIA 显卡驱动后的屏幕亮度调节问题
    算法算法算法
    Java transient关键字
    使用git和github管理自己的项目---基础操作学习[转]
    Linux 查看系统硬件信息[转]
    实现Servlet容器一
    nginx入门三
    nginx入门二
    nginx入门一
    centos7入门
  • 原文地址:https://www.cnblogs.com/guozhiguoli/p/3255354.html
Copyright © 2020-2023  润新知