Database select statement, trying to use wildcards to display specific rows [duplicate]












1















This question already has an answer here:




  • Is storing a delimited list in a database column really that bad?

    10 answers




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










share|improve this question















marked as duplicate by Strawberry mysql
Users with the  mysql badge can single-handedly close mysql questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 23 '18 at 16:16


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.











  • 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















This question already has an answer here:




  • Is storing a delimited list in a database column really that bad?

    10 answers




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










share|improve this question















marked as duplicate by Strawberry mysql
Users with the  mysql badge can single-handedly close mysql questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 23 '18 at 16:16


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.











  • 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












1








1








This question already has an answer here:




  • Is storing a delimited list in a database column really that bad?

    10 answers




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










share|improve this question
















This question already has an answer here:




  • Is storing a delimited list in a database column really that bad?

    10 answers




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





This question already has an answer here:




  • Is storing a delimited list in a database column really that bad?

    10 answers








mysql database






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 15:54









TrebuchetMS

2,0041619




2,0041619










asked Nov 23 '18 at 15:48









bobb1213131

728




728




marked as duplicate by Strawberry mysql
Users with the  mysql badge can single-handedly close mysql questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 23 '18 at 16:16


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by Strawberry mysql
Users with the  mysql badge can single-handedly close mysql questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 23 '18 at 16:16


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 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




    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




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






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




Thanks that seems to work
– bobb1213131
Nov 23 '18 at 15:58












1 Answer
1






active

oldest

votes


















2














Use



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





share|improve this answer




























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    Use



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





    share|improve this answer


























      2














      Use



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





      share|improve this answer
























        2












        2








        2






        Use



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





        share|improve this answer












        Use



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






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 23 '18 at 15:51









        krish KM

        4,1421727




        4,1421727















            Popular posts from this blog

            Contact image not getting when fetch all contact list from iPhone by CNContact

            count number of partitions of a set with n elements into k subsets

            A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks