Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

write sql query which returns all post and comments created by user, ordered by date. #11

Closed
rava-dosa opened this issue Mar 15, 2019 · 1 comment
Assignees

Comments

@rava-dosa
Copy link
Owner

No description provided.

@vaibhavpoddar
Copy link
Collaborator

select * from (select
'C' as CATEGORY,
comment_id as ID,
comment_content as CONT,
created_at as C_AT,
parent_id as P_ID,
post_id as PO_ID
from comment where user_id='1'
UNION ALL
select
'P' as CATEGORY,
post_id as ID,
content as CONT,
post_created_at as C_AT,
NULL as P_ID,
NULL as PO_ID
from post where user_id='1') as T order by T.C_AT DESC;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants