SQLTeam.com | Weblogs | Forums

SQL - syntax

Hi,

The query is below gives me the final result # 1. From the status column, i need to check to see if the same order is exists in table (2) then status show yes, else show no.

I am thinking about add the case after customer to check for order exits in mytbl2, but not sure about the syntax, can you help please?

select [order], customer from mytbl1 a 
inner join warehouse  b
on a.warehouse=b.warehouse

sql

hi

can you please explain a little more about what you are trying

normally when you write SQL you specify order by
.. then it returns results in that order

other wise the way the table results are returned is not guarenteed

one other idea do an order by for results and table
and then check the order by .. if there or not


select [order], customer,
    case when exists(select 1 from mytbl2 c where c.[order] = a.[order]) 
         then 'Yes' else 'No' end as status
from mytbl1 a 
inner join warehouse  b
on a.warehouse=b.warehouse