We help IT Professionals succeed at work.

specify yorn if field is populated in other relationsal table

292 Views
Last Modified: 2012-06-27
folks

i have two tables

workorder and asset

in my asset table I have data like so

asset    contract
car1      waranty1
car1      waranty2
car2      null
car3      repair


in my workorder table i have three fields

workid     asset  description
1             car1    broken
2             car2    inop


how can i add a field into my query to state in YORN form if the contract field is present
to that specific asset in my asset table like so

workid     asset  description    contracts exist?
1               car1    broken              Y
2               car2    inop                  N

All help will do


r
   
Comment
Watch Question

Guy Hengel [angelIII / a3]Billing Engineer
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2009

Commented:
select a.*, case when w.workid is null then 'N' else 'Y' end contract_exists
from asset a
left join workorder w
  on w.asset = a.asset
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.