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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:36:44+00:00 2026-06-03T06:36:44+00:00

I have two tables. The first table holds simple user data and has the

  • 0

I have two tables. The first table holds simple user data and has the columns

$username, $text, $image 

(this is called “USERDATA”).

The second table holds information about which users “follow” other users, which is set up with the columns

$username and $usertheyfollow 

(this is called “FOLLOWS”).

What I need to do is display the data individually to each user so that it is relevant to them. This means that userABC for instance, needs to be able to view the $text and $image inputs for all of the users whom he/she follows. To do this, I believe I need to write a sql query that involves first checking who the logged in user is (in this case userABC), then selecting all instances of $usertheyfollow on table FOLLOWS that has the corresponding value of "userABC." I then need to go back to my USERDATA table and select $text and $image that has a corresponding value of $usertheyfollow. Then I can just display this using echo command or the like…

How would I write this SQL query? And am I even going about the database architecture the right way?

  • 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-03T06:36:45+00:00Added an answer on June 3, 2026 at 6:36 am

    As it turns out, neither of these answers were right. @jam6459 was closest.

    The correct answer is the following:

    SELECT userdata.text, userdata.image, follows.userFollow
      FROM userdata
      LEFT JOIN follows ON follows.userFollow = userdata.username
      WHERE follows.userId = $username
    

    I also found it easier to not have a username correspond to an Id as in jam’s table example. This is because the same user can have multiple entries in “USERDATA”. I instead used username as the Id.

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

Sidebar

Related Questions

I have a database framework where I have two tables. The first table has
i have two data tables with the same structure the first one has one
I have xpath page.search(//table[@class='campaign']//table) which returns two tables. I need to choose only first
I have two tables, the first has a primary key that is an identity,
Suppose I have two columns in a table that represents a graph, the first
I have two tables. The first Holds a list of classes with basically an
I have two tables (well, two relevant for this question) : Bets (holds the
I have two tables in the same database with matching id's. The first table
i want to do for a table something like this. I have two tables
I have got two tables: tbl_sms tbl_bids The above two table holds something like

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.