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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:50:21+00:00 2026-06-10T17:50:21+00:00

while trying to learn sql i came across Learn SQL The Hard Way and

  • 0

while trying to learn sql i came across “Learn SQL The Hard Way” and i started reading it.
Everything was going fine then i thought ,as a way to practice, to make something like given example in the book (example consists in 3 tables pet,person,person_pet and the person_pet table ‘links’ pets to their owners).

I made this:

report table
+----+-------------+
| id | content     |
+----+-------------+
|  1 | bank robbery|
|  2 | invalid     |
|  3 | cat on tree |
+----+-------------+
notes table
+-----------+--------------------+
| report_id | content            |
+-----------+--------------------+
|  1        | they had guns      |
|  3        | cat was saved      |
+-----------+--------------------+

wanted result
+-----------+--------------------+---------------+
| report_id | report_content     | report_notes  |
+-----------+--------------------+---------------+
|  1        | bank robbery       | they had guns |
|  2        | invalid            | null or ''    |
|  3        | cat on tree        | cat was saved |
+-----------+--------------------+---------------+

I tried a few combinations but no success.

My first thought was

SELECT report.id,report.content AS report_content,note.content AS note_content
FROM report,note
WHERE report.id = note.report_id

but this only returns the ones that have a match (would not return the invalid report).
after this i tried adding IF conditions but i just made it worse.

My question is, is this something i will figure out after getting past basic sql
or can this be done in simple way?

Anyway i would appreciate any help, i pretty much lost with this.

Thank you.

EDIT: i have looked into related questions but havent yet found one that solves my problem.
I probably need to look into other statements such as join or something to sort this out.

  • 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-10T17:50:23+00:00Added an answer on June 10, 2026 at 5:50 pm

    You need to get to the chapter on OUTER JOINS, specifically, a LEFT JOIN

    SELECT report.id,report.content AS report_content,note.content AS note_content 
    FROM report
        LEFT JOIN note ON report.id = note.report_id 
    

    Note the ANSI-92 JOIN syntax as opposed to using WHERE x=y

    (You can probably do it using the older syntax you were using WHERE report.id *= note.report_id, if I recall the old syntax correctly, but I’d recommend the above syntax instead)

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

Sidebar

Related Questions

I'm trying to learn some Ember.js and while I realize everything is in flux
I am trying to learn about Objective-C for iPhone development, and while going through
While I am trying to learn WCF, and it seems straight-forward enough, I came
While trying to learn Play Framework I ran across the following problem: How do
I'm trying to learn JavaScript better, and while reviewing Node.js Module source I came
I am working on a little mini compiler while trying to learn some MIPS
I am trying to learn ruby and learn how to handle a while request
I am trying to learn and writting this part of code. while testing few
I'm trying to learn Rails better by looking at example applications, and while looking
Possible Duplicate: Why avoid while loops? I am trying to learn Python by following

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.