Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is the Access SQL for a subquery?

Status
Not open for further replies.

BigAndy

Programmer
Apr 17, 2001
1
GB
What is the Access SQL for a subquery that counts records from another table?

In SQL Server the following statemant works fine, can anyone help me make this work from an Access SQL statement?

SELECT U.Name, NumOfItems = (SELECT Count(*) FROM Item I WHERE I.UserIndex = U.UserIndex)
FROM User U

Thanks
Andy
 

TRY:

SELECT U.Name, NumOfItems AS (SELECT Count(*) FROM Item I WHERE I.UserIndex = U.UserIndex)
FROM User U

HTH

PsychPt@Hotmail.com
 
sorry, that was backwards

SELECT U.Name, (SELECT Count(*) FROM Item I WHERE I.UserIndex = U.UserIndex) AS NumOfItems
FROM User U

PsychPt@Hotmail.com



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top