Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8014261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:52:42+00:00 2026-06-04T19:52:42+00:00

The objective is a little bit difficult to explain, so please, notify me if

  • 0

The objective is a little bit difficult to explain, so please, notify me if you need more information.

I’m creating a blog, where people can post articles, but also promote posts of other users. The user posts and promoted posts will appear in its profile page.

To give you more information, this thing was already done in tumblr, or twitter (with retweet): In user profile, we have its tweets, but also tweets that he retweeted.

Here are the database tables:

Table “Posts”:

  • id
  • author_id
  • title
  • content
  • created

And the “Promotions” table (person X promotes the post Y):

  • id
  • promoter_id (the user id that promoted the post Y: Mr X)
  • post_id (the promoted post: Y)
  • created

Given a user id, I want to retrieve posts that he wrote and the posts that he promoted. The question is: what is the SQL (specially MySQL) query?

And order the list according on “created” field.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T19:52:44+00:00Added an answer on June 4, 2026 at 7:52 pm

    OK, I’ve got it. Here is the answer:

    SELECT *
    FROM Posts
    LEFT JOIN Promotions ON Promotions.post_id = Posts.id
    WHERE Posts.author_id = $userId
    OR Promotions.promoter_id = $userId
    

    So, the magic trick happens when mixing LEFT JOIN and the OR condition.

    Hope it will help.

    PS. Thanks for all participants.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am little confused about some concepts around Objective-C protocols and categories. Can protocols
I'm new to Objective-C and have a little bit of problem. I made an
I have a little foundation tool test (Objective-C) that I am playing with and
I'm having a little debate with a friend about Objective-C being a 3GL but
I am new to Objective-C and I am a little curious about how I
When I moved to Objective C (iOS) from C++ (and little Java) I had
I'm a beginner in Objective-c and i have a little issue that i'm sure
So, I understand that Categories in Objective-C can be used to add methods to
I have been reading about bit operators in Objective-C in Kochan's book, Programming in
I'm a little new to objective-C but have run across a problem that I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.