i couldn't find a good example of this in my texts.
I need to incorporate a if statement into my query. We add another field to invoices_staging_r100 called shiptype.
If the company name = PHYSICIANS SALES then shiptype=STOCK
ELSEIF the first 5 character of company<>first 5 characters of shipcompany THEN shiptype=DROP ELSE shiptype=STOCK.
Any ideas how to write this logic in my query?
select
if(left(company,5)<>left("ship_company",5),
'DROP',
if(company='PHYSICIANS SALES',
if(Index("ship_company",'SALES')>0,'STOCK','DROP'),'STOCK')) as shiptype, *
from invoices_staging_r100
I need to incorporate a if statement into my query. We add another field to invoices_staging_r100 called shiptype.
If the company name = PHYSICIANS SALES then shiptype=STOCK
ELSEIF the first 5 character of company<>first 5 characters of shipcompany THEN shiptype=DROP ELSE shiptype=STOCK.
Any ideas how to write this logic in my query?
select
if(left(company,5)<>left("ship_company",5),
'DROP',
if(company='PHYSICIANS SALES',
if(Index("ship_company",'SALES')>0,'STOCK','DROP'),'STOCK')) as shiptype, *
from invoices_staging_r100