[SQL] Query from different Database
I'm looking for a solution to make a query from two different databases. If anybody has an experience or know how to solve it, please help me. Thanks. ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html
Re: [SQL] Query from different Database
When grilled further on (Thu, 7 Oct 2004 16:52:38 +0800 (MYT)), Abdul Wahab Dahalan <[EMAIL PROTECTED]> confessed: > I'm looking for a solution to make a query from two different databases. If > anybody has an experience or know how to solve it, please help me. Thanks. > I believe that the contrib module dblink will do what you want, but I've never used it. Cheers, Rob -- 08:01:41 up 14 days, 10:28, 2 users, load average: 3.27, 2.64, 2.34 Linux 2.6.5-02 #8 SMP Mon Jul 12 21:34:44 MDT 2004 pgp0AX9QfGI92.pgp Description: PGP signature
Re: [SQL] Query from different Database
--- Robert Creager <[EMAIL PROTECTED]> escribió: > When grilled further on (Thu, 7 Oct 2004 16:52:38 > +0800 (MYT)), > Abdul Wahab Dahalan <[EMAIL PROTECTED]> confessed: > > > I'm looking for a solution to make a query from > two different databases. If > > anybody has an experience or know how to solve it, > please help me. Thanks. > > > > I believe that the contrib module dblink will do > what you want, but I've never > used it. > What about using schemas not databases. Selects between schemas are fully supported. Regards, Jaime Casanova _ Do You Yahoo!? Información de Estados Unidos y América Latina, en Yahoo! Noticias. Visítanos en http://noticias.espanol.yahoo.com ---(end of broadcast)--- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match
[SQL] help on a query
Hi all, This is one of those things I know I should know, but it's not coming to me. It's probably really simple. I have two related tables, registrations and receipts, related by the field registration_id. So registrations looks kinda like: registration_id bigint (primary key) foo varchar(10) bar varchar(20) and receipts looks like: receipt_id bigint (primary key) registration_id bigint (foreign key) amount float baz varchar(10) If someone has paid, there is a row in the receipts table for that registration ID#. I need to find a list of the registration IDs that *don't* have an entry in the receipts table. Thanks in advance!!! -- .Michelle -- Michelle Murrain mmurrain at dbdes dot com 413-222-6350 ph 617-889-0929 ph 952-674-7253 fax <--- new Page: [EMAIL PROTECTED] AIM:pearlbear0 ICQ:129250575 Skype: pearlbear Jabber: [EMAIL PROTECTED] "I see all the different religious traditions as paths for the development of inner peace, which is the true foundation of world peace. These ancient traditions come to us as a gift from our common past. Will we continue to cherish it as a gift and hand it over to the future generations as a legacy of our shared desire for peace?" - His Holiness the Dalai Lama ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org
Re: [SQL] help on a query
A query that should get the job done is: SELECT registration_id FROM registrations r WHERE NOT EXISTS ( SELECT 1 FROM receipts WHERE registration_id = r.registration_id ); There might be a more efficient version with JOINs that don't require a subquery, but this should get you started. -tfo On Oct 7, 2004, at 10:03 PM, Michelle Murrain wrote: Hi all, This is one of those things I know I should know, but it's not coming to me. It's probably really simple. I have two related tables, registrations and receipts, related by the field registration_id. So registrations looks kinda like: registration_id bigint (primary key) foo varchar(10) bar varchar(20) and receipts looks like: receipt_id bigint (primary key) registration_id bigint (foreign key) amount float baz varchar(10) If someone has paid, there is a row in the receipts table for that registration ID#. I need to find a list of the registration IDs that *don't* have an entry in the receipts table. Thanks in advance!!! -- .Michelle -- Michelle Murrain mmurrain at dbdes dot com 413-222-6350 ph 617-889-0929 ph 952-674-7253 fax <--- new Page: [EMAIL PROTECTED] AIM:pearlbear0 ICQ:129250575 Skype: pearlbear Jabber: [EMAIL PROTECTED] "I see all the different religious traditions as paths for the development of inner peace, which is the true foundation of world peace. These ancient traditions come to us as a gift from our common past. Will we continue to cherish it as a gift and hand it over to the future generations as a legacy of our shared desire for peace?" - His Holiness the Dalai Lama ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster
Re: [SQL] help on a query
On Friday 08 October 2004 07:10, Thomas F.O'Connell wrote: > A query that should get the job done is: > > SELECT registration_id > FROM registrations r > WHERE NOT EXISTS ( > SELECT 1 > FROM receipts > WHERE registration_id = r.registration_id > ); Don't, PLEASE, don't !!! drive this way : SELECT r.registration_id FROM registrations AS r LEFT OUTER JOIN receipts AS rec ON rec.registration_id = r.registration_id WHERE rec.registration_id IS NULL; ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org