By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,968 Members | 1,588 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,968 IT Pros & Developers. It's quick & easy.

Subquery problem

P: 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
Share this Question
Share on Google+
2 Replies


P: 3
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
100+
P: 143
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.