Jump to content

[SOLVED] problem when simulating FULL JOIN and grouping


vintox

Recommended Posts

I am trying to make a full join query

i found some simulating methods for simulating full join

but when i am using simulating and the selection is a grouping value like count()

i am getting a syntax error

 

the query is going like this:

SELECT p.*,COUNT(reply) as rcount 
	FROM reply r
		LEFT OUTER JOIN posts p
			ON p.id = r.post GROUP BY r.post
UNION
SELECT p.*,COUNT(reply) as rcount 
	FROM reply r
		RIGHT OUTER JOIN posts p
			ON p.id = r.post GROUP BY r.post
WHERE COUNT(reply) IS NULL

 

Thanks in advance

vintox

I don't get your SQL.

 

1. You're counting a table name? I'm referring to COUNT(reply). Isn't reply the table name?

2. Why are you using UNION on the same SQL?

3. WHERE COUNT(reply) IS NULL? What? ??? I don't think COUNT(reply) will ever be NULL. I can be 0. And change COUNT(reply) to rcount.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.