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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:11:57+00:00 2026-06-10T01:11:57+00:00

I have 3 tables on my database : Users : id ——- username 1

  • 0

I have 3 tables on my database :

Users :

id  ------- username
1            user1  
2            user2

writers

id  ------- name
4           writer4
5           writer5 
8           writer8

Following :

user_id  -----  follow  
1               5
1               8
2               5

so, now User1 follows writer5 and writer8 , and user2 follows writer5

I’m login to my app as user1 , when I go to the writers page I get list of all writers in the database ..
I just want to show in front of each writer whether I’m following this writer or not ..

List Writers Page example:

writer4     :follow
writer5     :unfollow (i'm following him now)
writer8     :unfollow (i'm following him now)
writer100     :follow 

my question is : Is there a query to get the full list of writers and give me a value=0 if I’m not (as user1) following this writer

any ideas ?
thanks ..

  • 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-10T01:11:58+00:00Added an answer on June 10, 2026 at 1:11 am

    You need to use CROSS JOIN in order for user to get all writers.

    SELECT b.name,if(c.userid is null, 'follow', 'unfollow') result
    FROM users a
            CROSS JOIN writers b
            LEFT JOIN following c
              on a.id = c.userid AND
                 b.id = c.follows
    WHERE a.id = 1
    

    SQLFiddle Demo

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

Sidebar

Related Questions

In my database I have three tables: Users: UserID (Auto Numbering), UserName, UserPassword and
OK, I have 3 database tables at the moment: users id: 1, 2 name:
I have the following tables: users userId|name items itemId|userId|description What I want to achieve:
I have three tables in my sample database: Users ID Username Password Roles ID
I have three database tables: users , user_profiles and friends : users id username
I have the following tables in a MySQL 5.x database: Users: id county_id state_id
I have 3 tables in my database :- tbl_roles(role_id,role_name); tbl_users(id,role_id,username,email,password); tbl_tickets_replies(id,ticket_id,user_id,role_id,comments) role_id, id, id
I have three database tables: users emails invitations Emails are linked to users by
I have an existing database with users and administrators in different tables. I am
So I have a mySQL database with a 'users' table which includes a username,

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.