在sybase中联接多个表

时间:2018-09-08 21:29:27

标签: sql sybase

我需要帮助来连接sybase数据库中的以下两个选择。

SELECT HOST_ENTRY.ID
      ,HOST.NAME
      ,HOST_ENTRY.TYPE
      ,HOST_ENTRY.NAME
      ,HOST_ENTRY.IP
      ,HOST_ENTRY.IP_LAST
      ,HOST_ENTRY.NETADDR
      ,HOST_ENTRY.MASK  
from HOST_ENTRY
INNER JOIN HOST
ON HOST_ENTRY.HOST_ID=HOST.ID;

SELECT  HOST_GRP_MEMBER.ID
       ,HOST_GROUP.NAME
       ,HOST.NAME
from HOST_GRP_MEMBER 
INNER JOIN HOST_GROUP ON HOST_GRP_MEMBER.GROUP_ID=HOST_GROUP.ID 
INNER JOIN HOST ON HOST_GRP_MEMBER.HOST_ID=HOST.ID 
ORDER BY HOST_GROUP.NAME

1 个答案:

答案 0 :(得分:0)

那-

SELECT HOST_ENTRY.ID
      ,HOST.NAME
      ,HOST_ENTRY.TYPE
      ,HOST_ENTRY.NAME
      ,HOST_ENTRY.IP
      ,HOST_ENTRY.IP_LAST
      ,HOST_ENTRY.NETADDR
      ,HOST_ENTRY.MASK  
      ,HOST_GRP_MEMBER.ID
      ,HOST_GROUP.NAME
      ,HOST.NAME
from HOST_ENTRY
INNER JOIN HOST ON HOST_ENTRY.HOST_ID=HOST.ID;
INNER JOIN HOST_GRP_MEMBER ON HOST_GRP_MEMBER.HOST_ID=HOST.ID
INNER JOIN HOST_GROUP ON HOST_GRP_MEMBER.GROUP_ID=HOST_GROUP.ID 
ORDER BY HOST_GROUP.NAME