1

I am trying to select all airlines where has the value 'Air Canada Rouge' for example, in the Airline columns there is sometimes concatenated values such as Air Canada, Air Canada Rouge, Air Transat. An example of the select statement I am currently using is:

select * from crs where Airline LIKE '%airlineName' OR Airline LIKE
'airlineName,%' OR Airline LIKE ',airlineName%';

This only works for rows that have Airlines that include 2 values such as Air Canada, Air Canada Rouge.

But I need the select statement to fetch rows with columns that has values that include 3 or 4 concatenated airlines.

How would I make a select statement to do this?

Thank you

TrebledJ
  • 8,713
  • 7
  • 26
  • 48
bobb1213131
  • 277
  • 1
  • 5
  • 16
  • 1
    As you want an exact match `where ',' + airline + ',' like '%,airlineName,%'` - But you should normalize the data to one-item-per-row then this becomes trivial, in most cases delimited data in a column is a recipe for disaster. – Alex K. Nov 23 '18 at 15:55
  • Thanks that seems to work – bobb1213131 Nov 23 '18 at 15:58

1 Answers1

2

Use

select * 
from crs 
where Airline LIKE '%airlineName%';
Krish
  • 5,917
  • 2
  • 14
  • 35