Thread: libpq++: how do I qualify by table name a resulting field when there are duplicate field names
libpq++: how do I qualify by table name a resulting field when there are duplicate field names
From
"Nicolae"
Date:
Hi All, I'm having a little problem with libpq++. Works great for everything else I'm doing. Table CUSTOMERS and TABLE deals are joined by CUSTOMERS.NUMBER = DEALS.CUSTOMERNUMBER Both tables have a NUMBER field (in the CUSTOMERS table this represents the customer number, in the DEALS table this represents the deal number - they are not joined). SELECT * FROM customers, deals WHERE customers.number = deals.customernumber AND customers.number = 1; When I do database->GetValue (0, "number"); I get back the number field of the customer table. But I want the number field from the deal table too. How do I get it? database->GetValue (0, "deals.number") gives me an error. Thanks for your help. If possible please cc: me via email (nick@strongholdtech.com)
Re: libpq++: how do I qualify by table name a resulting field when there are duplicate field names
From
Patrick Welche
Date:
On Wed, Mar 21, 2001 at 10:59:41AM -0500, Nicolae wrote: ... > SELECT * FROM customers, deals WHERE customers.number = deals.customernumber > AND customers.number = 1; > > When I do > > database->GetValue (0, "number"); > > I get back the number field of the customer table. > > But I want the number field from the deal table too. > How do I get it? > > database->GetValue (0, "deals.number") > > gives me an error. How about SELECT customers.number,deals.number FROM customers,deals WHERE customers.number = deals.customernumber AND customers.number = 1 database->GetValue(0,0) (I think it starts at 0..) == customers.number database->GetValue(0,1) == deals.number ? Cheers, Patrick