472,126 Members | 1,571 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,126 software developers and data experts.

Subquery problem

2
I am running the following query:

if (select IntExternalAccountID from ExternalAccount) = (select IntExternalAccountID from InternalAccount)
select * from InternalAccount
where AccountPurpose=2

and getting the following error
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

What I am attempting is if the values in ColumnA from Table1 = values in ColumnA from Table2

then return those results only when the AccountPurpose condition is met.

Please bear in mind I am a complete rookie in sql so try to keep it simple

I appreciate all the help I can get.
Nov 10 '06 #1
2 1806
I am running the following query:

if (select IntExternalAccountID from ExternalAccount) = (select IntExternalAccountID from InternalAccount)
select * from InternalAccount
where AccountPurpose=2

and getting the following error
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

What I am attempting is if the values in ColumnA from Table1 = values in ColumnA from Table2

then return those results only when the AccountPurpose condition is met.

Please bear in mind I am a complete rookie in sql so try to keep it simple

I appreciate all the help I can get.
try a join...
select tab1.ColA
from tab1, tab2
where
tab1.colA = tab2ColA

OR if you are trying for a different result set try using "where exists"

For example

Select * from from InternalAccount
where exists (select IntExternalAccountID from whateverTable ) and AccountPurpose=2
Nov 10 '06 #2
scripto
143 100+
I am running the following query:

if (select IntExternalAccountID from ExternalAccount) = (select IntExternalAccountID from InternalAccount)
select * from InternalAccount
where AccountPurpose=2

and getting the following error
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

What I am attempting is if the values in ColumnA from Table1 = values in ColumnA from Table2

then return those results only when the AccountPurpose condition is met.

Please bear in mind I am a complete rookie in sql so try to keep it simple

I appreciate all the help I can get.
Caffiene's got it right...

select ia.* from InternalAccount ia inner join ExternalAccount ea on ia.IntExternalAccountID = ea.IntExternalAccountID where ie.AccountPurpose=2
Nov 10 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Maarten | last post: by
3 posts views Thread by laurentc via AccessMonster.com | last post: by
1 post views Thread by mipo1984 | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.