Reply
Left Join Question
Old 01-18-2008, 12:25 PM Left Join Question
Skilled Talker

Posts: 60
Name: Nick Martin
Hello y'all...

So I am trying to figure out a query using a Left Outer Join.

I have 2 tables, tblService and tblCustomerService. What I need is for all services from the tblservice table to be displayed but I only want a 'customprice' from the tblcustomerservice table to appear where one is set.

So this is what I have:
Code:
SELECT 
(IF s.IsPart = 1 THEN 'Part' ELSE 'Service' ENDIF) as Category, s.code,s.price,c.customprice,
s.Description, c.pfp, (IF s.IsTaxable = 1 THEN 'X' ELSE '' ENDIF) 
as 
IsTaxable,  
 s.IsActive, 'NotEmpty', s.id
FROM tblService s LEFT OUTER JOIN tblcustomerservice c on s.id = c.serviceidPrice
What I need to do is only show 'PFP' and 'CustomPrice' where customerID = "somevalue"

For Clarity: I want all services to show up but only PFP and Custom price for those where a certain customerid is specified. How do I form this Order by or the WHERE clause.

Thanks in advance for the help!

-Nick
SpudNik is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 01-18-2008, 12:27 PM Re: Left Join Question
Skilled Talker

Posts: 60
Name: Nick Martin
BTW...

the customerid field is in the tblcustomerservice table.

Thanx
SpudNik is offline
Reply With Quote
View Public Profile
 
Old 01-31-2008, 03:05 AM Re: Left Join Question
Average Talker

Posts: 17
So you want all qualifying rows to show up, but customprice and PFP are blank unless customerid matches? If so, that is not in ORDER BY or WHERE, but in the actual row selection.


If I understand you correctly, you have:
... c.pfp, ...

And you want:
... (IF customerid=$x THEN c.pfp ELSE '' ENDIF), ...
__________________
DrivingForums.net - Defensive driving, fuel saving, discussion, debate, and more.
Crankshaft is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Left Join Question
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.10909 seconds with 12 queries