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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:10:09+00:00 2026-06-18T03:10:09+00:00

I have an sql query which seems to return an unexpected blank row. This

  • 0

I have an sql query which seems to return an unexpected blank row. This query has an right join to another table but when return the rows it returns me a null value..

  SELECT e.error_id, e.user_id, e.error_title, e.error_content, e.error_answers, 
         e.error_votes, e.error_views, e.error_added_date, u.user_name
  FROM errors e
  JOIN users u
    ON u.user_id=e.user_id
  RIGHT JOIN answers a
    ON a.error_id=e.error_id AND a.answer_accepted='1'
  GROUP BY e.error_id
  ORDER BY e.error_added_date DESC

This query should return me one single row but It returns me the expected row and one row with blank values.. Why is that?

Entries

+----------------------------------------------------------------------------------------------------+
answer_id | error_id | user_id | answer_content | answer_accepted | answer_votes | answer_added_date |
1         | 3        | 1       | text           | 0               | 0            | 2013-01-31 12:49:12
2         | 3        | 1       | text           | 1               | 1            | 2013-01-31 12:52:29
3         | 3        | 1       | text           | 0               |-1            | 2013-01-31 12:53:45
4         | 2        | 1       | text           | 0               |-1            | 2013-01-31 12:53:45
+----------------------------------------------------------------------------------------------------+

Results:

+-------------------------------------------------------------------------------+
|   1 | 1    | text |  3   | 0    |  2   |  2013-01-29 16:56:20  |  Mihai Matei |
|NULL | NULL | NULL | NULL | NULL | NULL |       NULL            |  NULL        |
+-------------------------------------------------------------------------------+
  • 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-18T03:10:10+00:00Added an answer on June 18, 2026 at 3:10 am

    This is happening because you are doing a Right Join. I think you want a Left Join or an Inner Join.

    A right join means return all the table rows on the right and the matching rows from the left. Because your result set doesn’t include any columns from the answers table (the right table), you can get a set of all nulls. In other words, there is a row in the answers table with no corresponding rows in the error and users table.

    Given the additional criteria in the comment on this answer, here’s the query I would try:

      SELECT e.error_id, e.user_id, e.error_title, e.error_content, e.error_answers, 
             e.error_votes, e.error_views, e.error_added_date, u.user_name
      FROM errors e
      JOIN users u
        ON u.user_id=e.user_id
      LEFT JOIN answers a
        ON a.error_id = e.error_id and a.answer_accepted = '1'
      WHERE a.answer_id is null
      GROUP BY e.error_id
      ORDER BY e.error_added_date DESC
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Right now I have this SQL query which is valid but always times out:
I have a sql query which looks like this - NSString *createSQL = @SELECT
using php, i have a sql query which works fine, dateentry only has the
I have following somewhat complex sql query which has horrible performance, 'certainly' due to
I have a T-SQL query as below which queries a table holding the search
I have this query which on executing in my sql command line client executes
My SQL seems to be letting me down this morning. I have a table
I have a SQL Server query which runs just fine -- until I add
In my Java code I have embedded a SQL query which fetches data from
i've got a SQL query which returns multiple rows, and i have : $data

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.