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

  • Home
  • SEARCH
  • 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 9078893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:43:54+00:00 2026-06-16T19:43:54+00:00

I’m creating a social network and I have a pretty specific case, and I’ve

  • 0

I’m creating a social network and I have a pretty specific case, and I’ve almost got the correct query. I have 6 tables that I’m merging into one query.
Table recent is used to find the exact rows on tables brostplain, egobrost, and brostpublic, it gets complicated when also finding a match on members and egos tables, where members.username will be matched to brostplain and brostpublic on column id, and egos.egoname will be matched to egobrost on column egoid. All of it is sorted by unix timestamp, in the recent.realtime column. Here’s the current query:

   SELECT recent.id, 
          recent.brosttype, 
          recent.postid, 
          recent.realtime, 
          members.username,
          egos.egoname, 
          brostplain.id, 
          brostplain.postid, 
          brostplain.content, 
          brostplain.up, 
          brostplain.down, 
          brostplain.timedata, 
          brostplain.realtime, 
          brostplain.attached, 
          brostplain.replies, 
          brostplain.ext, 
          brostplain.onpage, 
          brostplain.touser, 
          brostplain.isego, 
          brostplain.category, 
          egobrost.egoid, 
          egobrost.postid, 
          egobrost.content, 
          egobrost.up, 
          egobrost.down, 
          egobrost.timedata, 
          egobrost.realtime, 
          egobrost.attached, 
          egobrost.replies, 
          egobrost.ext, 
          egobrost.onpage, 
          egobrost.touser, 
          egobrost.isego, 
          egobrost.category, 
          brostpublic.id, 
          brostpublic.postid, 
          brostpublic.content, 
          brostpublic.up, 
          brostpublic.down, 
          brostpublic.timedata, 
          brostpublic.realtime, 
          brostpublic.attached, 
          brostpublic.replies, 
          brostpublic.ext, 
          brostpublic.category, 
          brostpublic.isego 
     FROM recent 
LEFT JOIN brostplain ON recent.brosttype=brostplain.brosttype 
      AND recent.postid=brostplain.postid 
LEFT JOIN brostpublic ON recent.brosttype=brostpublic.brosttype 
      AND recent.postid=brostpublic.postid 
LEFT JOIN egobrost ON recent.brosttype=egobrost.brosttype 
      AND recent.postid=egobrost.postid 
LEFT JOIN egos ON egos.egoid=egobrost.egoid
     JOIN members ON brostplain.id=members.id OR brostpublic.id=members.id 
    WHERE recent.id='2' ORDER BY recent.realtime DESC

Now this gets all the relevant rows, but it doesn’t return any results for egobrost rows due to the way egos table is joined, and I can’t figure out where to put the join or how to implement it. If I omit the JOIN on egos and remove egos.egoname from my SELECT, it will show the rows on egobrost table no problem, but I need the egoname for my output. Any help would be greatly appreciated.

EDIT (Solved): After much thought I solved this by adding LEFT to the JOIN on members. Now the result set is complete. Thanks to those who contributed.

  • 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-16T19:43:55+00:00Added an answer on June 16, 2026 at 7:43 pm

    Resolved by changing the JOIN on members to a LEFT JOIN, coinciding with the LEFT JOIN on egos. Here is the final query:

    SELECT recent.id, 
              recent.brosttype, 
              recent.postid, 
              recent.realtime, 
              members.username,
              egos.egoname, 
              brostplain.id, 
              brostplain.postid, 
              brostplain.content, 
              brostplain.up, 
              brostplain.down, 
              brostplain.timedata, 
              brostplain.realtime, 
              brostplain.attached, 
              brostplain.replies, 
              brostplain.ext, 
              brostplain.onpage, 
              brostplain.touser, 
              brostplain.isego, 
              brostplain.category, 
              egobrost.egoid, 
              egobrost.postid, 
              egobrost.content, 
              egobrost.up, 
              egobrost.down, 
              egobrost.timedata, 
              egobrost.realtime, 
              egobrost.attached, 
              egobrost.replies, 
              egobrost.ext, 
              egobrost.onpage, 
              egobrost.touser, 
              egobrost.isego, 
              egobrost.category, 
              brostpublic.id, 
              brostpublic.postid, 
              brostpublic.content, 
              brostpublic.up, 
              brostpublic.down, 
              brostpublic.timedata, 
              brostpublic.realtime, 
              brostpublic.attached, 
              brostpublic.replies, 
              brostpublic.ext, 
              brostpublic.category, 
              brostpublic.isego 
         FROM recent 
    LEFT JOIN brostplain ON recent.brosttype=brostplain.brosttype 
          AND recent.postid=brostplain.postid 
    LEFT JOIN brostpublic ON recent.brosttype=brostpublic.brosttype 
          AND recent.postid=brostpublic.postid 
    LEFT JOIN egobrost ON recent.brosttype=egobrost.brosttype 
          AND recent.postid=egobrost.postid 
    LEFT JOIN egos ON egos.egoid=egobrost.egoid
    LEFT JOIN members ON brostplain.id=members.id OR brostpublic.id=members.id 
        WHERE recent.id='2' ORDER BY recent.realtime DESC
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,

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.