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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:49:22+00:00 2026-05-30T20:49:22+00:00

This is my ERD for my database contains three tables: I want to retrieve

  • 0

This is my ERD for my database contains three tables:

enter image description here

I want to retrieve data from this tables, So I wrote following Query:

SELECT [SrvcDate], [Order].OrderID, [EmployeeID], [CustID], [ComputerID]
FROM [Order], [OtherService], [ServiceOrder]
WHERE [Order].[OrderID]=[OtherService].[OrderID]
OR [Order].OrderID= [ServiceOrder].OrderID

But this query only returns data if both [OtherService] and [ServiceOrder] tables contains any data. but If there is no data in one of the tables, query doesn’t retrieve data even if the other tables contain some data.

For example, say I have couple of records in [OtherService] table but I don’t have any data in [ServiceOrder] table, this query should bring all the data that are in [OtherService] table right? but it does not retrieve any record even though I have record in [OtherService] tables. Why is that?

  • 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-30T20:49:23+00:00Added an answer on May 30, 2026 at 8:49 pm

    Stop using old-style joins and please use the schema prefix. Your query should be:

    SELECT o.[SrvcDate], o.OrderID, o.[EmployeeID], o.[CustID], o.[ComputerID]
    --, I assume some columns from OtherService / ServiceOrder
    FROM dbo.[Order] AS o
    LEFT OUTER JOIN dbo.[OtherService] AS os
    ON os.OrderID = o.OrderID
    LEFT OUTER JOIN dbo.[ServiceOrder] AS so
    ON so.OrderID = o.OrderID;
    

    If you want there to be at least one row in either OtherService or ServiceOrder then add:

    WHERE COALESCE(os.OrderID, so.OrderID) IS NOT NULL
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to generate an entity-relationship diagram (ERD) from an existing PostgreSQL database.
I'm really struggling with this query. I have 4 tables (http://oberto.co.nz/db-sql.png): Invoice_Payement, Invoice, Client
This is my database table. Now I want to combine Branch_Id, Acc_no and Acc_Type
I have the following ERD and want to convert it EF 4.1 Code First
this is my code that I write it but I want to use LINQ
I have 4 tables, linked in a circular reference - I remember from college
Can you guys show me how to get this ERD in 5th normal form?
I hope someone can help with this please. I am trying to query an
I'm making an ERD of my database, and am stuck with a little dilemma.
Tables: Students Professors Entries (there’s no physical table intry in the database for entries

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.