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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:25:22+00:00 2026-06-10T00:25:22+00:00

i have this query, $query = ‘SELECT * FROM users where id =’.$_SESSION[‘user_id’].”; My

  • 0

i have this query,

$query = 'SELECT * FROM users where id ="'.$_SESSION['user_id'].'"'; 

My problem is that i don’t know how to left join it with another table..using another where or “On” clause..

can you please help me with the syntax of this?

It should be something like SELECT $query FROM users,retailer ON $query.user_id=retailer.user_id
….

"SELECT users.first_name, retailer.date
FROM users AS users
LEFT JOIN retailer AS retailer ON users.user_id=retailer.user_id
WHERE users.user_id=" . $_SESSION['user_id']

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-10T00:25:23+00:00Added an answer on June 10, 2026 at 12:25 am

    LEFT JOIN is pretty simple

    For your example:

    $query = "SELECT u.*, r.*
    FROM users AS u
    LEFT JOIN retailer AS r ON u.user_id=r.user_id
    WHERE u.user_id=" . $_SESSION['user_id']
    

    “AS” keyword creates alias so there is no need of making alias “users” of table “users”.

    Secondly, LEFT JOIN is useful if there is a chance that second table contains no matches to first one yet you still need that attribute to show – attributes of second table will have NULL values if no matches found.

    I’m not really sure you need a LEFT JOIN in your query.

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

Sidebar

Related Questions

I have this query: public function checkUser($phone) { $sql = SELECT name FROM users
I have this query that works: select name, location_id from all_names where location_id in
I have this query: SELECT DISTINCT phone, department FROM `users` WHERE ((SUBSTRING(phone,1,3) = '399')
I have this query that spawns the following error: SELECT * FROM Quota WHERE
I have this query: SELECT id, name FROM users WHERE ((id = 1) OR
I have this query to use in PHP: mysql_query(select count(*) from registeredUsers where email=.$_SESSION[username]);
I have this query... SELECT Distinct([TargetAttributeID]) FROM (SELECT distinct att1.intAttributeID as [TargetAttributeID] FROM AST_tblAttributes
I have this query: SELECT * From checkfinale where AssociateID = 51 AND `CompletedDate`
I have this query: SELECT * FROM bookmarks WHERE id=? ORDER BY title ASC,
I have this query: UPDATE student_info set grade = (SELECT tempTable.grade FROM tempTable WHERE

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.