Over the next few days we are going to start the migration to a new forum application. I'm going to start with high post count and active users. You may receive an invitation to the new forums. It's not spam. It's just me trying to seed the user base. My goal is to open it up over the weekend.

Once we open the site we'll block registrations here. We should be open shortly on the new site.

SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 select if null
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

macuser
Starting Member

Poland
2 Posts

Posted - 12/05/2013 :  01:55:15  Show Profile  Reply with Quote
I have select:

select *
from serviceorders as zlecenie
--join orderitems as linijki on linijki.serviceorder_id = zlecenie.id
where zlecenie.id = 38

table: serviceorders(headers) is joined to orderitems(items).
In above case(id=38) - I have serviceorder, but i don't have orderitems(in remaining case data are present in both tables).
If I ask only for serviceorders=38 - I receive result, but if I ask about orderitems too I will receive empty result(but I need data from serviceorders(such Name, adress).

How can I ask about data from serviceorders in case when orderitems is empty but I need data from serviceorders(such Name, adress)?

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 12/05/2013 :  02:08:24  Show Profile  Reply with Quote

select *
from serviceorders as zlecenie
left outer join orderitems as linijki 
on linijki.serviceorder_id = zlecenie.id
where zlecenie.id = 38


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

macuser
Starting Member

Poland
2 Posts

Posted - 12/05/2013 :  02:54:21  Show Profile  Reply with Quote
many thanks, it works!
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000