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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:36:37+00:00 2026-06-10T14:36:37+00:00

I do not have a very advanced knowledge in complex queries in Mysql. I

  • 0

I do not have a very advanced knowledge in complex queries in Mysql.

I have a system where a user can follow each other and stay on top of the news from him.

I have two tables: one for users and one that keeps the connection between two users.

Do I need a hint system of friends, example would be Facebook friends that you suggested.

I wanted to do something. For example I follow a particular user and this follows another user, but I do not follow that user he follows. We three are from the same town where Sao Paulo, I wanted to make a query that suggested that user I still do not follow, because he is a friend of a friend of mine and because he is in the same city as me.

My tables are:

tb_usuario
id | name  | city
1  | Halan | Sao Paulo
2  | John  | Sao Paulo
3  | Maria | Sao Paulo

tb_ligacao

id | user_id | id_usuario_seguido
1  | 1       | 2
2  | 2       | 3

Can someone help me?

  • 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-10T14:36:39+00:00Added an answer on June 10, 2026 at 2:36 pm

    It seems like you are trying to see who is a friend of a friend. To do this, with your code:

    select * from tb_usario as a left join tb_ligacao as b on a.id = b.id_usuario_seguido where b.user_id = 1
    

    The code above will get all friends for the user with the ID of 1. To get all of their friends, you would loop through and run the same code but change the ID to the variable of the loop.

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

Sidebar

Related Questions

I'd like to firstly point that I'm not very good at advanced MySQL just
I have not worked with parameters in ADO.Net very much. I'm writing a custom
I have not used jquery much yet and not very familiar with it. Trying
I have a very simple MVC site that is returning a 404 not found
i have a very simple question, actually this is not the question, this is
My $.ajax() is not serializing the button name and value. I have a very
We have encountered a very strange class not found problem in our web app
I have written a very very very simple!! script in php. header redirection not
I'm not very good at PHP and would like to have a PHP function
Hi I have some experience with programming but I'm not very good with pointers.

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.