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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:57:15+00:00 2026-06-17T10:57:15+00:00

I currently have: SELECT * FROM submissions AS s LEFT JOIN submission_category AS sc

  • 0

I currently have:

SELECT * FROM submissions AS s
    LEFT JOIN submission_category AS sc ON s.submission_category = sc.sub_cat_id    
    JOIN hospitals      AS h  ON h.hospital_id        = sc.main_hospital_id
    JOIN products       AS p  ON p.product_id         = s.product_id
    JOIN product_group  AS pg ON pg.id                = p.product_group_id 
    JOIN progress_steps AS ps ON sc.approval_step     = ps.step_id
    WHERE s.approval_status='2' 
    AND sc.user_id='$mask5'

The problem is that sc has 3 rows and s has 6 rows. I need to return all six rows but currently it is only returning 3, one of each from s that corresponds to sc.

Based on the suggestion I am now trying:

SELECT * FROM submissions AS s
LEFT JOIN submission_category AS sc ON (s.submission_category = sc.sub_cat_id AND sc.user_id='$mask5' ) 
JOIN hospitals      AS h  ON h.hospital_id        = sc.main_hospital_id
JOIN products       AS p  ON p.product_id         = s.product_id
JOIN product_group  AS pg ON pg.id                = p.product_group_id 
JOIN progress_steps AS ps ON sc.approval_step     = ps.step_id
WHERE s.approval_status='2'

But still getting three rows, not six?

  • 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-17T10:57:16+00:00Added an answer on June 17, 2026 at 10:57 am

    Having columns of LEFT JOINed table[s] in WHERE “turns” LEFT JOIN into INNER (sc.user_id = ‘$mask5’ always returns NULL or false in case there is no corresponding row in submission_category ). Move sc.user_id=... into join condition :

    ....
    LEFT JOIN submission_category AS sc ON (s.submission_category = sc.sub_cat_id AND 
     sc.user_id='$mask5' )
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the code that I currently have: SELECT `A`.* FROM `A` LEFT JOIN
I currently have a query similar to: SELECT users.fname, users.lname, sales.date FROM users LEFT
I currently have this code: $rawsql2 = SELECT * FROM _erc_foffices n INNER JOIN
I currently have this code: $rawsql2 = SELECT * FROM _erc_foffices n INNER JOIN
Currently we have dueling select lists where you can select multiple employees from Available
I currently have a select-case that will read a name field from a recordset,
I currently have a query $query = SELECT * FROM routes ORDER BY id
Currently I have written: SELECT IT_ID, SUBSTR (SYS_CONNECT_BY_PATH (grp , ','), 2) GROUPS FROM
I currently have the following SQL statement MySQL Query: SELECT c.day, COUNT(*) FROM calendar
I currently have a server side paging query as such: SELECT * FROM (SELECT

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.