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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select Count

Status
Not open for further replies.

manking

MIS
Jan 29, 2003
28
US
Any Ideas whats wrong with this?

<CFQUERY name=&quot;gLis&quot; datasource=&quot;#DSName#&quot;>
SELECT DISTINCT Types.ID, Types.Type,
(Select Count(*)
From Listings
Where TypeID = types.ID AND Listings.Approved = 1) AS TotalListings
FROM Types INNER JOIN Listings ON Types.ID = Listings.TypeID
ORDER BY Types.Type
</CFQUERY>


Error Message
ODBC Error Code = 42000 (Syntax error or access violation)


[TCX][MyODBC]You have an error in your SQL syntax near 'Select Count(*) From Listings Where TypeID = types.ID AND Listings.Approved' at line 2

 
Mysql does not support subqueries.

You have to rewrite with a (outer) join and group by
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top