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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:18:29+00:00 2026-05-26T18:18:29+00:00

I will try and explain this the best way I can. I have a

  • 0

I will try and explain this the best way I can.

I have a SQL query which does 3 inner joins with 3 tables to match two ID’s (i.e I have a ‘Item’ table and a ‘itemType’ table. item.itemTypeID is linked with itemType.id).

In my code, if there is no ItemType associated with an Item, then the item.itemTypeID is set to -1.

However when it comes to this query, there is no such itemType with ID -1, so it doesn’t come back with a record.

I need it to come back with all the records that have an itemType, but also all those records with a itemType as -1, and set the relevant returned elements to NULL.

My SQL query is as follows;

`
SELECT items.id

 , items.code
 , items.description
 , items.expirydate
 , items.batchnumber
 , items.serialnumber
 , items.orderref
 , items.datepurchased
 , items.price
 , items.consigcalloff
 , items.commodity_qty
 , itemtypes.code
 , itemtypes.description
 , locations.code
 , locations.description
 , keepers.code
 , keepers.fname
 , keepers.lname
FROM items inner join itemtypes ON items.type = itemtypes.id inner join keepers ON items.keeper = keepers.id inner join locations ON items.location = locations.id`
  • 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-05-26T18:18:30+00:00Added an answer on May 26, 2026 at 6:18 pm

    You’re going to need an outer join.. This will return all records from the items table, irrespective of whether they have a match in the itemType table or not. When no match exists, the itemType fields will be null..

    SELECT items.id
     , items.code
     , items.description
     , items.expirydate
     , items.batchnumber
     , items.serialnumber
     , items.orderref
     , items.datepurchased
     , items.price
     , items.consigcalloff
     , items.commodity_qty
     , itemtypes.code
     , itemtypes.description
     , locations.code
     , locations.description
     , keepers.code
     , keepers.fname
     , keepers.lname
    FROM items 
           left outer join join itemtypes ON items.type = itemtypes.id 
           inner join keepers ON items.keeper = keepers.id 
           inner join locations ON items.location = locations.id`
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'll try to explain this as best as I can. I have a form
HI, I have the following scenario which I will try to explain as best
I'll try to explain this as best I can. I have an ArrayList of
It's kinda hard to explain, but I will try my best. I have this
I think this may not be possible, will try and explain as best as
Alright, Ill try to explain this as best as I can first... My program
Good day, i will try to explain my problem as best as i can.
I'll try to explain this as best as i can, but i appologize if
This is a bit tricky to explain but I will try my best to
Hmm. I found this which seems promising: http://sourceforge.net/projects/mjpg-streamer/ Ok. I will try to explain

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.