469,324 Members | 1,442 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,324 developers. It's quick & easy.

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 1697
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
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by mdpf | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.