473,699 Members | 2,383 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Subquery problem

2 New Member
I am running the following query:

if (select IntExternalAcco untID from ExternalAccount ) = (select IntExternalAcco untID 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 1937
NeedCaffeine
3 New Member
I am running the following query:

if (select IntExternalAcco untID from ExternalAccount ) = (select IntExternalAcco untID 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 IntExternalAcco untID from whateverTable ) and AccountPurpose= 2
Nov 10 '06 #2
scripto
143 New Member
I am running the following query:

if (select IntExternalAcco untID from ExternalAccount ) = (select IntExternalAcco untID 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.IntExternalA ccountID = ea.IntExternalA ccountID where ie.AccountPurpo se=2
Nov 10 '06 #3

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

Similar topics

3
2351
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 from table 1 with an checkbox and
7
9217
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 a table (c) re-queries another table using a subquery which references the inserted table (correlated or not)
8
19593
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 couple of tables in my database using INNER JOINS and the WHERE clause to specify the required constraints. However, I also want to read two fields from a *single* record from a table called 'Locations' and then apply one of these field's values...
7
2369
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 which a part may be composed. I have a table of parts and their subparts. The problem is that each of those subparts may be composed of smaller component parts. The subpart would then be listed in the Part field linked to each of its subparts in...
5
6583
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 following SQL statement. INSERT INTO OrderItems (ClientID, ProductID, OrderHeaderID, Quantity, Dispatched, BackOrdered) SELECT ClientID, ProductID, 1371 AS OrderHeaderID, Quantity, Dispatched, BackOrdered FROM Basket WHERE RequisitionID = 1369 The...
3
3516
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 (PrimaryKey) - Quote I do some calculations on these data:
1
1496
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 Microsoft Data Link to a Sybase database (DSN changed a couple months ago but the connection string was updated successfully for the new 12.51 version of ASE) and the destination is a link to a local SQL Server 2000 database. The transformation has...
13
3826
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. This is what I came up with: SELECT GI.generalinfoid AS GeneralInfoId, max(GI.FirstName) AS FirstName, max(GI.LastName) AS LastName, max(TI.ImagingDate) AS ImagingDate, Max(EM.embolizationDate) AS embolizationDate FROM tblImaging AS TI RIGHT JOIN...
1
2079
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, nither "fetch first 1 rows only" because this return a error too. Any sugestion? this es the SQL... SELECT C.NOMBRE,V.COBJCOD,CS.DESC,V.CSUBCOD, N.NOMBRE,CS.NIVEL,V.SUBLIBRO, V.TSUBLIBRO,CS.CAT5COD,CAT7COD, ...
1
7752
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 "." after it. For instance, a simple example illustrates how it works : SELECT subA.* FROM (SELECT , FROM ) AS subA becomes (after saving as a querydef in Access) : SELECT subA.*
0
8687
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8615
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9034
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8914
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7750
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4376
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3057
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2347
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2009
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.