Home » SQL & PL/SQL » SQL & PL/SQL » sql query trouble
sql query trouble [message #2817] Wed, 14 August 2002 09:56 Go to next message
Heaven
Messages: 1
Registered: August 2002
Junior Member
Hi i am having trouble getting my head around an sql query. The query:

"SELECT t.pub_name, tl.accountno
FROM tenant_login tl, tenants t
WHERE t.pub_name = '"+name+"' AND t.accountno = tl.accountno";

produces a list of pub names and account numbers when an account number exists both in tenant_login and tenants.

How do i create a query that lists the pubname and account numbers where the account number exists in tenants but NOT in tenant_login?

Thanks
Re: sql query trouble [message #2818 is a reply to message #2817] Wed, 14 August 2002 10:01 Go to previous messageGo to next message
Keith
Messages: 88
Registered: March 2000
Member
You need an outer join:

SELECT t.pub_name, tl.accountno
FROM tenant_login tl, tenants t
WHERE t.pub_name = '"+name+"'
AND t.accountno = tl.accountno(+)
Re: sql query trouble [message #2821 is a reply to message #2817] Thu, 15 August 2002 00:39 Go to previous message
Keith
Messages: 88
Registered: March 2000
Member
my mistake - misread the question!

:-)
Previous Topic: Stumped? Procedure Error
Next Topic: inserting a value of varchar2 containig new line
Goto Forum:
  


Current Time: Fri Apr 26 09:59:06 CDT 2024