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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:39:10+00:00 2026-06-03T06:39:10+00:00

ok this is hard to explain… i have the following tables: table : words

  • 0

ok this is hard to explain…

i have the following tables:

table : words
table: word_progress
table: word_set

foreign keys:
words.id = word_set.word_id
word_progress.word_id = words.id
word_progress.user_id = users.id

basically a word is in a word_set. word_progress (it keeps score on a certain word) relates to a user_id and word_id.

the problem is sometimes there is not an entry in word_progress for user_id and word_id. but when it IS there, i wanna be able to use word_progress in the WHERE part of the query. but if it is not there I dont. My work around at the moment is before running the statement, i do an “insert IGNORE IF EXISTS into work_progress (word_id,user_id) values (?,?)” to make sure its there

i have this query

select 
words.* , 
word_progress.progress from words

left join word_progress on word_progress.word_id = words.id
left join word_set on word_set.id = words.word_set_id        

where word_set.id = ?  and word_progress.user_id = ?

but… the problem is sometimes there is no word_progress entry for that word

how can i do this?

  • 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-03T06:39:12+00:00Added an answer on June 3, 2026 at 6:39 am

    you’re already left-joining, so when there’s no data available, you’ll just get null as value for your word_progress-fields. just check for that like this:

    ...
    and
      (
        word_progress.user_id is null
      or
        word_progress.user_id = ?
      )
    

    another way would be to add the user-restriction directly to the join-criteria like this:

    ...
    left join word_progress
      on word_progress.word_id = words.id
      and word_progress.user_id = ?
    ...
    

    and drop that criteria from the where-part.

    note that, in both cases, you’ll have to handle the null-cases for progress later in your code properly.

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

Sidebar

Related Questions

This is a problem which is hard to explain in words, though I have
This is kind of hard to explain. I have an absolutely positioned floating secondary
Ok this is hard to explain, but here goes. I have a 3D list
This is quite hard to explain. I have a class which should support the
This is a bit hard to explain in words ... I'm trying to calculate
it's pretty simple but is kind of hard to explain. I have this image
This is a hard one to explain but here goes. I have 2 arrays,
This is hard to explain so I will do my best. I have a
This may be hard to explain. I have been developing a program for about
This will be a bit hard to explain but I am going to have

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.