Re: [SQL] conditional FROM

2011-12-10 Thread Jasen Betts
On 2011-12-10, Richard Klingler wrote: > Good day... > > I'm trying to build a query for PGSQL 9.1 where a table has two > references with only one being used depending of the type of entry.. > > For example, the table has following simplified structure: > > portid primary key >

Re: [SQL] conditional FROM

2011-12-10 Thread Bèrto ëd Sèra
I guess this is what you mean: create table node( id bigint primary key); insert into node values (1); insert into node values (2); create table card( id integer primary key); insert into card values (1); insert into card values (2); create table port_activity ( portid integer primary k

Re: [SQL] conditional FROM

2011-12-10 Thread Andreas Kretschmer
Richard Klingler wrote: > This seems to do the trick... > > select arp.ip, arp.mac, arp.port2time, arp.time, arp.hostname, arp.vlan > from arp, port, node > where > arp.arp2port = port.portid and port.name = 'Fa1/0/1' > and port.port2node = node.nodeid > and node.name like 'no

Re: [SQL] conditional FROM

2011-12-10 Thread Richard Klingler
This seems to do the trick... select arp.ip, arp.mac, arp.port2time, arp.time, arp.hostname, arp.vlan from arp, port, node where arp.arp2port = port.portid and port.name = 'Fa1/0/1' and port.port2node = node.nodeid and node.name like 'nodename%' union select arp.ip, arp.ma

Re: [SQL] conditional FROM

2011-12-10 Thread David Johnston
On Dec 10, 2011, at 11:03, Richard Klingler wrote: > Good day... > > I'm trying to build a query for PGSQL 9.1 where a table has two > references with only one being used depending of the type of entry.. > > For example, the table has following simplified structure: > >portidprima

Re: [SQL] conditional FROM

2011-12-10 Thread Andreas Kretschmer
Richard Klingler wrote: > Good day... > > I'm trying to build a query for PGSQL 9.1 where a table has two > references with only one being used depending of the type of entry.. > > For example, the table has following simplified structure: > > portid primary key > port2no

[SQL] conditional FROM

2011-12-10 Thread Richard Klingler
Good day... I'm trying to build a query for PGSQL 9.1 where a table has two references with only one being used depending of the type of entry.. For example, the table has following simplified structure: portid primary key port2node index to table node por