473,398 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 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 1928
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

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

Similar topics

3
by: Maarten | last post by:
I've the following problem: Table1 serie | dir Table2 serie | user I am making a webpage in php to administrate the values in the db. What I want is that I select all series...
7
by: Andrew Mayo | last post by:
Here's a really weird one for any SQL Server gurus out there... We have observed (SQL Server 2000) scenarios where a stored procedure which (a) begins a transaction (b) inserts some rows into...
8
by: Andrew McNab | last post by:
Hi folks, I have a problem with an MS Access SQL query which is being used in an Access Report, and am wondering if anyone can help. Basically, my query (shown below) gets some records from a...
7
by: K. Crothers | last post by:
I administer a mechanical engineering database. I need to build a query which uses the results from a subquery as its input or criterion. I am attempting to find all of the component parts of...
5
by: Rod | last post by:
I have a client site where the code below has been working happily for at least four months. The site is using SQL Server 7. The code is ASP.NET Last week an error appeared related to the...
3
by: laurentc via AccessMonster.com | last post by:
Hi. I have an issue with my Access project. I have rather big tables of data (about 11 000 rows). These tables are historical product quotations, so they are very simple : - MyDate...
1
by: Docster2005 | last post by:
Hi folks, A DTS package we have run for years now no longer works. The specific part that is not working is a subquery in the SOURCE object of a transformation. The source is based on a...
13
by: ThePrinceIsRight | last post by:
I have a problem with using a subquery in MS Access. The purpose of the sub-query is to create a list of people who have had doctor exams in the past 6 months and exclude them from the main query....
1
by: mipo1984 | last post by:
I have subquery into a principal query, and i need the subquery return me only the last row of all results, but i can`t use "order by <field> desc " in the subquery because this return me an error,...
1
NeoPa
by: NeoPa | last post by:
Access QueryDefs Mis-save Subquery SQL Access stores its SQL for Subqueries in a strange manner :s It seems to replace the parentheses "()"with square brackets "" and (often) add an extraneous...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.