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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:10:29+00:00 2026-05-20T23:10:29+00:00

Here he comes to confuse his day! (should be my handle from now on)

  • 0

Here he comes to confuse his day! (should be my handle from now on)

Im confused and very much lost.

I need to figure out how to make a select statement for getting FriendID to relate to there UserID

enter image description here

enter image description here

As you can see FriendID relates to the UserID of my User table, so if FriendID = 2 then display UserID 2 details.

What im trying to do is if im UserID 1 I want to display all my friends, my userid is set by a session,

What I need to do is find out who my friends are so Select FriendID from freinds where SessionID = UserID then some how figure out who friendsID belongs to in the User table and display his firstname, secondname and his picturepath.

Very confusing…

My table structure looks like this:

enter image description here

So to sum it up what I need in my select command:

To find out who im friends with (currentsession UserID has FriendID’s)
Display FirstName, SecondName, picturepath of friendID related to his own UserID

Example:

I (userID=1) have FriendID 2 = UserID 2 so select firstname, secondname from User where UserID=2

I could have relational problems with my table structure tho not sure.

I hope u can understand my confusion:

EDIT for those that cant see the images of my db

    SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;

SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;

SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';



CREATE SCHEMA IF NOT EXISTS `gymwebsite2` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci ;

USE `gymwebsite2` ;



-- -----------------------------------------------------

-- Table `gymwebsite2`.`User`

-- -----------------------------------------------------

CREATE  TABLE IF NOT EXISTS `gymwebsite2`.`User` (

  `UserID` INT NOT NULL AUTO_INCREMENT ,

  `Email` VARCHAR(245) NULL ,

  `FirstName` VARCHAR(45) NULL ,

  `SecondName` VARCHAR(45) NULL ,

  `DOB` VARCHAR(45) NULL ,

  `Location` VARCHAR(45) NULL ,

  `Aboutme` VARCHAR(1045) NULL ,

  `username` VARCHAR(45) NULL ,

  `password` VARCHAR(45) NULL ,

  PRIMARY KEY (`UserID`) )

ENGINE = InnoDB;





-- -----------------------------------------------------

-- Table `gymwebsite2`.`WallPosting`

-- -----------------------------------------------------

CREATE  TABLE IF NOT EXISTS `gymwebsite2`.`WallPosting` (

  `idWallPosting` INT NOT NULL AUTO_INCREMENT ,

  `UserID` INT NOT NULL ,

  `Wallpostings` VARCHAR(2045) NULL ,

  PRIMARY KEY (`idWallPosting`) ,

  INDEX `fk_WallPosting_User` (`UserID` ASC) ,

  CONSTRAINT `fk_WallPosting_User`

    FOREIGN KEY (`UserID` )

    REFERENCES `gymwebsite2`.`User` (`UserID` )

    ON DELETE NO ACTION

    ON UPDATE NO ACTION)

ENGINE = InnoDB;





-- -----------------------------------------------------

-- Table `gymwebsite2`.`Pictures`

-- -----------------------------------------------------

CREATE  TABLE IF NOT EXISTS `gymwebsite2`.`Pictures` (

  `idPictures` INT NOT NULL AUTO_INCREMENT ,

  `UserID` INT NOT NULL ,

  `picturepath` VARCHAR(1045) NULL ,

  PRIMARY KEY (`idPictures`) ,

  INDEX `fk_Pictures_User1` (`UserID` ASC) ,

  CONSTRAINT `fk_Pictures_User1`

    FOREIGN KEY (`UserID` )

    REFERENCES `gymwebsite2`.`User` (`UserID` )

    ON DELETE NO ACTION

    ON UPDATE NO ACTION)

ENGINE = InnoDB;





-- -----------------------------------------------------

-- Table `gymwebsite2`.`Friends`

-- -----------------------------------------------------

CREATE  TABLE IF NOT EXISTS `gymwebsite2`.`Friends` (

  `idFriends` INT NOT NULL AUTO_INCREMENT ,

  `UserID` INT NOT NULL ,

  `FriendID` INT NOT NULL ,

  PRIMARY KEY (`idFriends`) ,

  INDEX `fk_Friends_User2` (`FriendID` ASC) ,

  INDEX `fk_Friends_User1` (`UserID` ASC) ,

  UNIQUE INDEX `FriendID_UNIQUE` (`FriendID` ASC) ,

  CONSTRAINT `fk_Friends_User2`

    FOREIGN KEY (`FriendID` )

    REFERENCES `gymwebsite2`.`User` (`UserID` )

    ON DELETE NO ACTION

    ON UPDATE NO ACTION,

  CONSTRAINT `fk_Friends_User1`

    FOREIGN KEY (`UserID` )

    REFERENCES `gymwebsite2`.`User` (`UserID` )

    ON DELETE NO ACTION

    ON UPDATE NO ACTION)

ENGINE = InnoDB;







SET SQL_MODE=@OLD_SQL_MODE;

SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;

SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
  • 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-20T23:10:30+00:00Added an answer on May 20, 2026 at 11:10 pm
    select u.FirstName, u.SecondName, p.picturePath
    from User u
    join Friends f
      on f.FriendId = u.UserId
    join Pictures p
      on p.UserId = u.UserId
    where f.UserId = SessionId ( <-- sessionId is your id)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new at Eclipse and the Android applications making so here comes a very
I am trying to understand this inline assembly code which comes from _hypercall0 here
What does the PCGPRLEN-1..28 means here?? Where does this 4 bit comes from? alt
Here comes a simple question, for all those who know javascript. I made an
As I don't want to hijack another thread here comes my question about mappings.
I've harnessed a project released on internet a long time ago. Here comes the
Something like this: _declspec(align(16)) float dens[4]; //Here the code comes. F32vec4 S_START, Pos, _Vector
Here's a question that comes up again and again in C++ class implementation. I'm
Here's the issue: When a Patient comes into the doctor's office, they can have
First timer here, and total noob when it comes to PHP and JavaScript. I

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.