DBA2010
asked on
SQL 2008
I tried to use a where statment on my code but its not working
select * from Tablename
Where Order.OrderNo like (Invoice.OrderNo +'%')
Example:
Order.OrderNo = 1000
Invoice.OrderNo = 1000C
Is there another way to do that?
Thanks
select * from Tablename
Where Order.OrderNo like (Invoice.OrderNo +'%')
Example:
Order.OrderNo = 1000
Invoice.OrderNo = 1000C
Is there another way to do that?
Thanks
cast as order.orderno as varchar
select *
from Order
inner join invoice on charindex(cast(Order.order No as varchar), Invoice.OrderNo, 1) > 0
select *
from Order
inner join invoice on charindex(cast(Order.order
ASKER
why is that?
To compare fields from two tables, they need to be linked in some way, in this case I'm using a join
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
you need to join the tables
select *
from Order
inner join invoice on charindex(Order.orderNo, Invoice.OrderNo, 1) > 0