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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:18:14+00:00 2026-05-15T05:18:14+00:00

I have a fairly simple query I’m try to write. If I run the

  • 0

I have a fairly simple query I’m try to write.

If I run the following query:

SELECT parts.id, parts.type_id 
FROM parts 
WHERE parts.type_id=1 
  OR parts.type_id=2 
  OR parts.type_id=4 
ORDER BY parts.type_id;

I get all the rows I expect to be returned. Now when I try to grab the parent_unit from another table with the following query six rows suddenly drop out of the result:

SELECT parts.id, parts.type_id, sp.parent_unit 
FROM parts, serialized_parts sp 
WHERE (parts.type_id=1 OR parts.type_id=2 OR parts.type_id=4) 
  AND sp.parts_id = parts.id 
ORDER BY parts.type_id

In the past I’ve never really dealt with ORs in my queries so maybe I’m just doing it wrong. That said I’m guessing it’s just a simple mistake. Let me know if you need sample data and I’ll post some. Thanks.

  • 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-15T05:18:15+00:00Added an answer on May 15, 2026 at 5:18 am

    Check the value for parts.parts_id for the 6 missing rows. You probably don’t have a corresponding value in sp.parts_id (or maybe the value for parts.parts_id is null). Note that it has to be an exact match for the join to work.

    As an alternative to the OR string you can use parts.type_id IN (1,2,4). It works the same as the listed ORs but is easier to read.

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

Sidebar

Related Questions

I have a fairly simple pagination query used to get rows from a table
I have a fairly simple query: SELECT invoice_id WHERE employee_id = 'XXXX' AND customer_id
I have a fairly simple Linq query (simplified code): dim x = From Product
I have a fairly simple block of code. Sub Run(Name) on error resume next
I have a fairly simple query that runs super fast most of the time
I have a fairly weird 'bug' with a simple query, and I vaguely remember
I have a fairly simple requirement for a query API which I need to
I've got a fairly simple query that I have working in command line, and
I'm having trouble crafting a fairly simple query with Doctrine... I have two arrays
I have a fairly simple query that I keep getting timeouts (it takes over

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.