How to create join in Database Manager?

Hi All,

I'm trying to become a "power" user, and do a fancy SQL query, but it's not working for me.  I can't find a discussion about doing a basic join.

In English pseudocode, I'm trying to:

select IfName as Interface from Interfaces

select IPAddress as 'IP Address' from NodeIPAddresses

where the InterfaceIndex.Interfaces = InterfaceIndex.NodeIPAddresses

and

select Caption from NodesData

where the NodeID.NodeIPAddresses =  NodeID.NodesData

So, I can get a query that looks like:

Interface          IPAddress          Caption

Gi3/6               1.2.3.4                 MyRouterA

Po1                  5.6.7.8                MySwitchB

So, I'm trying to write a query which will selct the interface name from Interfaces, the IP Address from Node IP Addresses, and the Caption from NodesData.

I can manage A select statement, but don't know how to do the joins.

SELECT IfName as Name, InterfaceAlias as Description, NodeID, InterfaceID, InterfaceIndex FROM [dbo].[Interfaces]

Parents
  • So, here's my SQL query to pull from 4 tables and build a list of interfaces, with names, IP's, subnets.  Next up on my to do, is to put it together (in SQL) to assemble a reverse DNS name.  ( I already exported it to CSV and did that in an Excel table).  Thanks for everyone's help.

    SELECT i.NodeID as "NodeID", i.InterfaceName as "Int Name", i.Caption, i.InterfaceAlias as Description, i.IfName,
    nip.IPAddress as "IP Address", nip.SubnetMask as "SubnetMask",
    nd.Caption as "Node Name", 
    ncp.Comments as "Node Comments"

    From [Interfaces] as i, [NodeIPAddresses] as nip, [NodesData] as nd, [NodesCustomProperties] as ncp

    where i.NodeID = nip.NodeID

    and

    nip.NodeID = nd.NodeID

    and

    nd.NodeID = ncp.NodeID

    and

    i.InterfaceIndex=nip.InterfaceIndex

  • Ps.  I'm working on writing a blog about this, but Thwack is giving me an error about posting the blog article.

Reply Children
No Data