English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Hello!

I am trying to write SQL code for my coursework using Access but it says "more than one record can not be returned by a sub query".

However the same code (query) works as long as it returns only one record.

Note I have to generate queries using SQL I am not allowed to use query builder.

2007-10-01 09:49:18 · 4 answers · asked by Anonymous in Computers & Internet Programming & Design

4 answers

You can choose for a query to return a specific row count...

SELECT TOP 1 * FROM Assignments

SELECT TOP 10 * FROM Assignments

etc.

2007-10-01 09:55:55 · answer #1 · answered by Anonymous · 0 0

Try to use joins to reduce sets rather than in the where clause and using sub queries.

I'm guessing you're using an "=" some where which is why you're getting the error in the sub-query.

if you need more specific help, feel free to e-mail me and I'll assist.

2007-10-01 10:03:34 · answer #2 · answered by hsueh010 7 · 0 0

all records will be returned that matchyour query. use the word DISTINCT after SELECT.

ex.) SELECT DISTINCT Clients FROM dbo.Users WHERE 1=1 AND Name = Client

2007-10-01 09:55:10 · answer #3 · answered by sk8er0114 3 · 0 1

As stated above, use TOP 1:

SELECT * FROM Employees WHERE EmployeeID IN
(
SELECT TOP 1 EmployeeID FROM SalesData
WHERE SalesData.Something = something
)

2007-10-01 10:09:14 · answer #4 · answered by kryzchek79 5 · 0 0

fedest.com, questions and answers