Hi My table consists of:
source destination LA BOS LA BOS Seattle BOS Bos LA BOS Seattle NY Seattle CA LA LA CA LA Chicago CA BOS BOS Seattle
I am trying to fetch if my source either contains boston or seattle and if either my destination contains boston or seattle. so result should look like this:
source destination Seattle BOS BOS Seattle BOS Seattle
My query does not work:
select source,destination from dbo.flights where source in ('BOS','Seattle') or destination in('BOS','Seattle')
Advertisement
Answer
As @jarlh said in a comment, use AND
instead of OR
:
select source, destination from dbo.flights where source in ('BOS','Seattle') AND destination in ('BOS','Seattle')