Reputation: 187
Can anyone please tell me why I keep getting an error right before the where clause in this query? It works fine if I don't have any where clause.
SELECT
(SELECT COUNT(DISTINCT threadid) FROM thread) AS threads,
(SELECT COUNT(DISTINCT postid) FROM post) AS posts
WHERE
post.dateline >= 1299905258 AND
thread.dateline >= 1299905258
Both table have the dateline field. Is it a syntax issue or am I trying to accomplish something that can't be done this way?
Upvotes: 0
Views: 40
Reputation: 10880
Where is the FROM
clause?
Basically when you dont have a WHERE clause it is just getting 2 columns for you. When you define a where clause that means you are filtering results from some table .. so now you need the FROM
You can try this
SELECT
(SELECT COUNT(DISTINCT threadid) FROM thread WHERE dateline >= 1299905258) AS threads,
(SELECT COUNT(DISTINCT postid) FROM post WHERE dateline >= 1299905258) AS posts
Upvotes: 2