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 283897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:24:45+00:00 2026-05-12T05:24:45+00:00

I have a problem that I can’t figure out myself. I’ve tried using LEFT

  • 0

I have a problem that I can’t figure out myself. I’ve tried using LEFT JOIN etc but nothing seems to work. I’m using MySQL so you know.

I’m building a little blogportal for me and my friends and all users have their own blog.

database:

users:
id,
username,
password,
etc

blog:
id,
title,
text,
user_id,
etc

relations
follower_id,
following_id

I query my own blogposts like this:

SELECT * FROM microblog WHERE user_id = {$user_id} ORDER BY posted DESC

and i list my friends like this:

SELECT * FROM users, relations WHERE relations.follower_id = {$user_id} AND relations.following_id = users.id

That was the easy part. BUT.

I rather JOIN the tables somehow because I also want to list my friends blogposts inside my loop. But I don’t just want the post to show, I also want some info about the user that posted that one so then I must get some info from the users table as well. And that’s what bothers me! I can’t figure it out.

In short: I want to list my own blog posts and all the users I’m friend with within my own loop. And I also want to display username and email beside the posts.

Hope you understand what I mean.

/Tobias

Sweden

  • 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-05-12T05:24:45+00:00Added an answer on May 12, 2026 at 5:24 am

    How about?

    select 
        u.username, 
        u.email, 
        m.title, 
        m.text 
           -- ... etc
    from microblog m
         inner join user u on m.user_id = u.id
    where  m.user_id = {$user_id} 
        or m.user_id in (select 
                             following_id 
                         from relations r 
                         where follower_id = {$user_id}
                        );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Left Join LINQ and using Bitwise Comparisons. I have a problem that can be
I have a problem that I can't figure out. I'm building a small framework
I have a problem that I can't figure out what to do next. I
i have a problem that i can't solve ! (sqlite3, but i think it
I have the problem that an specific step in Ant can only be executed
I have a script that constantly segfaults - the problem that I can't solve
I have a weird date rounding problem that hopefully someone can solve. My client
I have a problem that can essentially be viewed as a graph. I'm considering
I have a problem that can be simplified as follows: I have a particular
I have problem that seems to be rather trivial but I was not able

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.