RE: [suse-programming-e] selecting more that 2 tables based on 1 subquery find an error (revision)
You are actually talking about 3 tables. You must link the first 2 tables. I am assuming you have custid as a field on description table. If you have a large number of rows, make sure you properly tune your database. I am assuming this is a small number of rows for learning. I am reformatting your query. It should go something like this.... select c.custid, cd.description, c.company, c.title, c.salutation, c.firstname, c.lastname, c.address, c.postcode, c.city, c.areacode, c.phone, c.mobilephone, c.fax, c.email from customer as c, customerdescription as cd where c.custid = cd.cust_id and c.custid in (select custid from sven1); Hope this helps.. -Scott -----Original Message----- From: Prabu Subroto [mailto:prabu_subroto@yahoo.com] Sent: Monday, July 26, 2004 7:41 AM To: suse-programming-e@suse.com Subject: [suse-programming-e] selecting more that 2 tables based on 1 subquery find an error (revision) Dear my friends... I am using SuSE 9.1 and postgres. I want to "select" query 2 tables. one is "customer" and one is "customer.description" but the customer records that I want to "select" are only what in subquery result. Here what I've done: postgres@patrix:~> psql kv Welcome to psql 7.4.2, the PostgreSQL interactive terminal. Type: \copyright for distribution terms \h for help with SQL commands \? for help on internal slash commands \g or terminate with semicolon to execute query \q to quit kv=# select c.custid, cd.description, c.company, c.title, c.salutation, c.firstname, c.lastname, c.address, c.postcode, c.city, c.areacode, c.phone, c.mobilephone, c.fax, c.email from customer as c, customerdescription as cd where c.custid in (select custid from sven1); Terminated postgres@patrix:~> Anybody could give me any solution? Thank you very much in advance. __________________________________ Do you Yahoo!? Yahoo! Mail - 50x more storage than other providers! http://promotions.yahoo.com/new_mail -- To unsubscribe, email: suse-programming-e-unsubscribe@suse.com For additional commands, email: suse-programming-e-help@suse.com Archives can be found at: http://lists.suse.com/archive/suse-programming-e
It's solved. Thank you very much for your kindness. --- "Wenzel, Scott" <scott_wenzel@BUDCO.com> wrote:
You are actually talking about 3 tables. You must link the first 2 tables. I am assuming you have custid as a field on description table. If you have a large number of rows, make sure you properly tune your database. I am assuming this is a small number of rows for learning. I am reformatting your query.
It should go something like this.... select c.custid, cd.description, c.company, c.title, c.salutation, c.firstname, c.lastname, c.address, c.postcode, c.city, c.areacode, c.phone, c.mobilephone, c.fax, c.email from customer as c, customerdescription as cd where c.custid = cd.cust_id and c.custid in (select custid from sven1);
Hope this helps.. -Scott
-----Original Message----- From: Prabu Subroto [mailto:prabu_subroto@yahoo.com] Sent: Monday, July 26, 2004 7:41 AM To: suse-programming-e@suse.com Subject: [suse-programming-e] selecting more that 2 tables based on 1 subquery find an error (revision)
Dear my friends...
I am using SuSE 9.1 and postgres.
I want to "select" query 2 tables. one is "customer" and one is "customer.description" but the customer records that I want to "select" are only what in subquery result.
Here what I've done:
postgres@patrix:~> psql kv Welcome to psql 7.4.2, the PostgreSQL interactive terminal.
Type: \copyright for distribution terms \h for help with SQL commands \? for help on internal slash commands \g or terminate with semicolon to execute query \q to quit
kv=# select c.custid, cd.description, c.company, c.title, c.salutation, c.firstname, c.lastname, c.address, c.postcode, c.city, c.areacode, c.phone, c.mobilephone, c.fax, c.email from customer as c, customerdescription as cd where c.custid in (select custid from sven1);
Terminated postgres@patrix:~>
Anybody could give me any solution?
Thank you very much in advance.
__________________________________ Do you Yahoo!? Yahoo! Mail - 50x more storage than other providers! http://promotions.yahoo.com/new_mail
-- To unsubscribe, email: suse-programming-e-unsubscribe@suse.com For additional commands, email: suse-programming-e-help@suse.com Archives can be found at: http://lists.suse.com/archive/suse-programming-e
__________________________________ Do you Yahoo!? Yahoo! Mail - 50x more storage than other providers! http://promotions.yahoo.com/new_mail
Am Montag, 26. Juli 2004 15:58 schrieb Wenzel, Scott: [...]
It should go something like this.... select c.custid, cd.description, c.company, c.title, c.salutation, c.firstname, c.lastname, c.address, c.postcode, c.city, c.areacode, c.phone, c.mobilephone, c.fax, c.email from customer as c, customerdescription as cd where c.custid = cd.cust_id and c.custid in (select custid from sven1);
why not use a join over all tables? select c.custid, cd.description, c.company, c.title, c.salutation, c.firstname, c.lastname, c.address, c.postcode, c.city, c.areacode, c.phone, c.mobilephone, c.fax, c.email from customer as c, customerdescription as cd, sven1 as s where c.custid = cd.cust_id and c.custid = s.custid; Jan
participants (3)
-
Jan.Trippler@t-online.de
-
Prabu Subroto
-
Wenzel, Scott