Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



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

Posts: 60
Name: Nick Martin
Trades: 0
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
 
 
Register now for full access!
Old 01-18-2008, 01:27 PM Re: Left Join Question
Skilled Talker

Posts: 60
Name: Nick Martin
Trades: 0
BTW...

the customerid field is in the tblcustomerservice table.

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

Posts: 17
Trades: 0
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), ...
__________________

Please login or register to view this content. Registration is FREE
- 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 Search this Thread
Search this Thread:

Advanced Search

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

BB 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.11681 seconds with 12 queries