Jump to content

[SOLVED] problem when simulating FULL JOIN and grouping


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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.