SQL query to find a list of city names that dont start with vowels












10














I'm trying to query the list of CITY names from table - STATION that do not start with vowels with results that cannot contain duplicates.
The table just has id, city, population



This is the query that I've written



SELECT DISTINCT CITY FROM STATION 
WHERE CITY RLIKE '[^bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ].*';


This gives a wrong answer. What am I doing wrong here?










share|improve this question






















  • try the NOT RLIKE '^[aeiouAEIOU].*$'
    – Tin Tran
    Apr 14 '16 at 22:05
















10














I'm trying to query the list of CITY names from table - STATION that do not start with vowels with results that cannot contain duplicates.
The table just has id, city, population



This is the query that I've written



SELECT DISTINCT CITY FROM STATION 
WHERE CITY RLIKE '[^bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ].*';


This gives a wrong answer. What am I doing wrong here?










share|improve this question






















  • try the NOT RLIKE '^[aeiouAEIOU].*$'
    – Tin Tran
    Apr 14 '16 at 22:05














10












10








10


1





I'm trying to query the list of CITY names from table - STATION that do not start with vowels with results that cannot contain duplicates.
The table just has id, city, population



This is the query that I've written



SELECT DISTINCT CITY FROM STATION 
WHERE CITY RLIKE '[^bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ].*';


This gives a wrong answer. What am I doing wrong here?










share|improve this question













I'm trying to query the list of CITY names from table - STATION that do not start with vowels with results that cannot contain duplicates.
The table just has id, city, population



This is the query that I've written



SELECT DISTINCT CITY FROM STATION 
WHERE CITY RLIKE '[^bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ].*';


This gives a wrong answer. What am I doing wrong here?







mysql






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Apr 14 '16 at 21:59









ZeusZeus

7832829




7832829












  • try the NOT RLIKE '^[aeiouAEIOU].*$'
    – Tin Tran
    Apr 14 '16 at 22:05


















  • try the NOT RLIKE '^[aeiouAEIOU].*$'
    – Tin Tran
    Apr 14 '16 at 22:05
















try the NOT RLIKE '^[aeiouAEIOU].*$'
– Tin Tran
Apr 14 '16 at 22:05




try the NOT RLIKE '^[aeiouAEIOU].*$'
– Tin Tran
Apr 14 '16 at 22:05












25 Answers
25






active

oldest

votes


















12














try this.



SELECT DISTINCT CITY 
FROM STATION
WHERE CITY NOT RLIKE '^[aeiouAEIOU].*$'





share|improve this answer





























    8














    A ^ in regular expressions can have different meanings, depending on its location. When it's the first character in a regex, it refers to the start of the string. But when it's the first character in a set, like [^abc], it means not one of. And when it appears elsewhere, it just refers to the ^ itself.



    So you would need something like:



    SELECT DISTINCT CITY FROM STATION 
    WHERE CITY RLIKE '^[bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ].*';


    or, just exclude the letters you don't want:



    SELECT DISTINCT CITY FROM STATION 
    WHERE CITY RLIKE '^[^aeiouAEIOU].*';





    share|improve this answer





























      3














      Query the list of CITY names from STATION that either do not start with vowels or do not end with vowels. IN ORACLE



      select distinct city 
      from station
      where regexp_like(city, '^[^aeiouAEIOU]|*[^aeiouAEIOU]$');


      In MySQL -



       select distinct city 
      from station
      where city RLIKE '^[^aeiouAEIOU].*' OR
      city RLIKE '^.*[^aeiouAEIOU]$';





      share|improve this answer































        2














        select distinct city from station 
        where city Not like 'A%' and city Not like 'E%' and city Not like 'I%' and
        city Not like 'o%' and city not like 'U%';





        share|improve this answer































          1














          This worked on MS SQL SERVER:



          select distinct city from station where city NOT like '[aeuio]%' Order by City;





          share|improve this answer























          • it worked on MS SQL SERVER
            – abhinay vijay
            Dec 24 '16 at 8:41



















          1














          SELECT DISTINCT CITY from STATION  WHERE CITY RLIKE '^[^aeiouAEIOU].*$'





          share|improve this answer























          • This works for mysql
            – SunnyShineColorado
            Sep 16 '16 at 0:48



















          1














          select distinct city from station where city regexp
          '^[^aeiou].*[^aeiou]$'


          If your query doesn't starts and ends with a vowel.






          share|improve this answer





























            1














            Try the following:



            SELECT DISTINCT CITY FROM STATION
            WHERE CITY REGEXP '^[^aeiou].*';


            MySQL Ref.: https://dev.mysql.com/doc/refman/5.5/en/regexp.html






            share|improve this answer































              1














              Simple example without regular expressions



              SELECT DISTINCT 
              City
              FROM Station
              WHERE LEFT(City, 1) NOT IN ("a", "e", "i", "o", "u");





              share|improve this answer































                1














                I tried this.



                select distinct city
                from station
                where substring(city,1,1) not in('A','E','I','O','U');





                share|improve this answer































                  0














                  SELECT DISTINCT CITY FROM STATION 
                  WHERE CITY RLIKE '^.*[bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ]$';





                  share|improve this answer































                    0














                    In MS SQL:



                    Select DISTINCT CITY
                    FROM
                    STATION
                    Where CITY NOT LIKE 'A%' AND CITY NOT LIKE 'E%' AND CITY NOT LIKE 'I%' AND CITY NOT LIKE 'O%' AND CITY NOT LIKE 'U%';





                    share|improve this answer





























                      0














                      you can use
                      select distinct city from station where city not RLIKE '^[aeiouAEIOU].*'






                      share|improve this answer





























                        0














                        select distinct CITY from STATION where left(CITY,1) not in ('a','e','i','o','u') or right(CITY,1) not in ('a','e','i','o','u');






                        share|improve this answer





























                          0














                          select DISTINCT CITY from STATION where CITY NOT LIKE '[a,e,i,o,u]%'






                          share|improve this answer





























                            0














                            try this one




                            SELECT DISTINCT CITY FROM STATION WHERE
                            LOWER(SUBSTR(CITY,LENGTH(CITY),1)) IN ('a','e','i','o','u');







                            share|improve this answer





























                              0














                              Select Distinct City from Station where City Like '[^aeiou]%';


                              MS SQL Server Tested.






                              share|improve this answer































                                0














                                 SELECT DISTINCT city from STATION
                                WHERE city NOT LIKE "[aieuo]%[aieuo] [aieuo]%[aieuo]"
                                AND city NOT LIKE "[aieuo]%[aieuo]";


                                The first NOT LIKE means, that each word of the two-word city names doesn't start and end with vowels. The second NOT LIKE is for one-word city names.






                                share|improve this answer





























                                  0














                                  select distinct city from station where (
                                  left(city,1) not in ('a','e','i','o','u')
                                  and
                                  right(city,1) not in ('a','e','i','o','u')
                                  );





                                  share|improve this answer



















                                  • 1




                                    PLease add some explanation why this code answers the question.
                                    – Hintham
                                    Oct 21 '18 at 9:34










                                  • Thank you for this code snippet, which might provide some limited, immediate help. A proper explanation would greatly improve its long-term value by showing why this is a good solution to the problem, and would make it more useful to future readers with other, similar questions. Please edit your answer to add some explanation, including the assumptions you've made.
                                    – FrankerZ
                                    Oct 21 '18 at 16:05



















                                  0














                                  In ORACLE:



                                  select 
                                  distinct(city)
                                  from station
                                  where regexp_like (city, '^[^A|E|I|O|U](*)');


                                  There is no need to specify the ending letter in this solution. It's not called out for in the problem presented.






                                  share|improve this answer























                                  • Between the two carots ( ^^ ) and after the U, there should be [ ]. They didn't post for some reason.
                                    – Aaron W.
                                    Nov 19 '18 at 20:41



















                                  0














                                  for oracle



                                  select distinct 
                                  city
                                  from station
                                  where regexp_like(city, '^[^aeiouAEIOU].*');





                                  share|improve this answer































                                    0














                                    select distinct city from station where city regexp '^[^aeiou].*[^aeiou]$'


                                    distinct: to avoid the duplication on the following column



                                    regexp: MySql function (regexp) to obtain Regular Expressions. expression starts with ^ and ends with $. In Oracle its regexp_like (city,'RegEx') Regular Expressions With Oracle Database.



                                    [^...] means any character NOT contain any of ...
                                    [^...]. means a single character NOT contain any of ...
                                    [^...].* means first character NOT contain any of ...
                                    [^...].*[^...] means first character NOT contains any of ... AND not ends with ...
                                    [^aeiou].*[^aeiou] mean the first character NOT starts with vowels AND not ends with vowels






                                    share|improve this answer























                                    • While this code may answer the question, providing additional context regarding how and why it solves the problem would improve the answer's long-term value.
                                      – Alexander
                                      Nov 25 '18 at 11:28



















                                    0














                                    Mysql we can use this.



                                    select distinct city from station where city regexp '^[^aeiou].*';


                                    To Know More About MySQL Regular Expression



                                    For Oracle we can use



                                    select distinct(city) from station where regexp_like (city, '^[^AEIOU](*)');


                                    To Know More About Oracle Regular Expression



                                    For MS SQL Server



                                    select distinct city from station where city not like '[aeuio]%';





                                    share|improve this answer





























                                      -1














                                      select distinct city from station where
                                      city not in
                                      (select distinct city from station where
                                      (city like "A%" or
                                      city like "E%" or
                                      city like "I%" or
                                      city like "O%" or
                                      city like "U%"
                                      ));


                                      This will work i guess.






                                      share|improve this answer























                                      • please provide justification, why it will work.
                                        – piyushj
                                        Oct 18 '16 at 3:27



















                                      -1














                                      SELECT DISTINCT CITY
                                      FROM STATION
                                      WHERE CITY NOT RLIKE '[aeiouAEIOU]$'



                                      This works for MYSQL






                                      share|improve this answer





















                                      • You've anchored the pattern to the end of the string, not the start. This gets you cities that DON'T end in a vowel, the opposite of what was asked. Try
                                        – Paul Campbell
                                        Dec 9 '17 at 11:11










                                      • Try SELECT 'Aberdeen' NOT RLIKE '[aeiouAEIOU]$' and see what you get.
                                        – Paul Campbell
                                        Dec 9 '17 at 11:19











                                      Your Answer






                                      StackExchange.ifUsing("editor", function () {
                                      StackExchange.using("externalEditor", function () {
                                      StackExchange.using("snippets", function () {
                                      StackExchange.snippets.init();
                                      });
                                      });
                                      }, "code-snippets");

                                      StackExchange.ready(function() {
                                      var channelOptions = {
                                      tags: "".split(" "),
                                      id: "1"
                                      };
                                      initTagRenderer("".split(" "), "".split(" "), channelOptions);

                                      StackExchange.using("externalEditor", function() {
                                      // Have to fire editor after snippets, if snippets enabled
                                      if (StackExchange.settings.snippets.snippetsEnabled) {
                                      StackExchange.using("snippets", function() {
                                      createEditor();
                                      });
                                      }
                                      else {
                                      createEditor();
                                      }
                                      });

                                      function createEditor() {
                                      StackExchange.prepareEditor({
                                      heartbeatType: 'answer',
                                      autoActivateHeartbeat: false,
                                      convertImagesToLinks: true,
                                      noModals: true,
                                      showLowRepImageUploadWarning: true,
                                      reputationToPostImages: 10,
                                      bindNavPrevention: true,
                                      postfix: "",
                                      imageUploader: {
                                      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                                      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                                      allowUrls: true
                                      },
                                      onDemand: true,
                                      discardSelector: ".discard-answer"
                                      ,immediatelyShowMarkdownHelp:true
                                      });


                                      }
                                      });














                                      draft saved

                                      draft discarded


















                                      StackExchange.ready(
                                      function () {
                                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f36634742%2fsql-query-to-find-a-list-of-city-names-that-dont-start-with-vowels%23new-answer', 'question_page');
                                      }
                                      );

                                      Post as a guest















                                      Required, but never shown

























                                      25 Answers
                                      25






                                      active

                                      oldest

                                      votes








                                      25 Answers
                                      25






                                      active

                                      oldest

                                      votes









                                      active

                                      oldest

                                      votes






                                      active

                                      oldest

                                      votes









                                      12














                                      try this.



                                      SELECT DISTINCT CITY 
                                      FROM STATION
                                      WHERE CITY NOT RLIKE '^[aeiouAEIOU].*$'





                                      share|improve this answer


























                                        12














                                        try this.



                                        SELECT DISTINCT CITY 
                                        FROM STATION
                                        WHERE CITY NOT RLIKE '^[aeiouAEIOU].*$'





                                        share|improve this answer
























                                          12












                                          12








                                          12






                                          try this.



                                          SELECT DISTINCT CITY 
                                          FROM STATION
                                          WHERE CITY NOT RLIKE '^[aeiouAEIOU].*$'





                                          share|improve this answer












                                          try this.



                                          SELECT DISTINCT CITY 
                                          FROM STATION
                                          WHERE CITY NOT RLIKE '^[aeiouAEIOU].*$'






                                          share|improve this answer












                                          share|improve this answer



                                          share|improve this answer










                                          answered Apr 14 '16 at 22:06









                                          Tin TranTin Tran

                                          5,41421226




                                          5,41421226

























                                              8














                                              A ^ in regular expressions can have different meanings, depending on its location. When it's the first character in a regex, it refers to the start of the string. But when it's the first character in a set, like [^abc], it means not one of. And when it appears elsewhere, it just refers to the ^ itself.



                                              So you would need something like:



                                              SELECT DISTINCT CITY FROM STATION 
                                              WHERE CITY RLIKE '^[bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ].*';


                                              or, just exclude the letters you don't want:



                                              SELECT DISTINCT CITY FROM STATION 
                                              WHERE CITY RLIKE '^[^aeiouAEIOU].*';





                                              share|improve this answer


























                                                8














                                                A ^ in regular expressions can have different meanings, depending on its location. When it's the first character in a regex, it refers to the start of the string. But when it's the first character in a set, like [^abc], it means not one of. And when it appears elsewhere, it just refers to the ^ itself.



                                                So you would need something like:



                                                SELECT DISTINCT CITY FROM STATION 
                                                WHERE CITY RLIKE '^[bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ].*';


                                                or, just exclude the letters you don't want:



                                                SELECT DISTINCT CITY FROM STATION 
                                                WHERE CITY RLIKE '^[^aeiouAEIOU].*';





                                                share|improve this answer
























                                                  8












                                                  8








                                                  8






                                                  A ^ in regular expressions can have different meanings, depending on its location. When it's the first character in a regex, it refers to the start of the string. But when it's the first character in a set, like [^abc], it means not one of. And when it appears elsewhere, it just refers to the ^ itself.



                                                  So you would need something like:



                                                  SELECT DISTINCT CITY FROM STATION 
                                                  WHERE CITY RLIKE '^[bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ].*';


                                                  or, just exclude the letters you don't want:



                                                  SELECT DISTINCT CITY FROM STATION 
                                                  WHERE CITY RLIKE '^[^aeiouAEIOU].*';





                                                  share|improve this answer












                                                  A ^ in regular expressions can have different meanings, depending on its location. When it's the first character in a regex, it refers to the start of the string. But when it's the first character in a set, like [^abc], it means not one of. And when it appears elsewhere, it just refers to the ^ itself.



                                                  So you would need something like:



                                                  SELECT DISTINCT CITY FROM STATION 
                                                  WHERE CITY RLIKE '^[bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ].*';


                                                  or, just exclude the letters you don't want:



                                                  SELECT DISTINCT CITY FROM STATION 
                                                  WHERE CITY RLIKE '^[^aeiouAEIOU].*';






                                                  share|improve this answer












                                                  share|improve this answer



                                                  share|improve this answer










                                                  answered Apr 14 '16 at 22:07









                                                  ArjanArjan

                                                  8,34812032




                                                  8,34812032























                                                      3














                                                      Query the list of CITY names from STATION that either do not start with vowels or do not end with vowels. IN ORACLE



                                                      select distinct city 
                                                      from station
                                                      where regexp_like(city, '^[^aeiouAEIOU]|*[^aeiouAEIOU]$');


                                                      In MySQL -



                                                       select distinct city 
                                                      from station
                                                      where city RLIKE '^[^aeiouAEIOU].*' OR
                                                      city RLIKE '^.*[^aeiouAEIOU]$';





                                                      share|improve this answer




























                                                        3














                                                        Query the list of CITY names from STATION that either do not start with vowels or do not end with vowels. IN ORACLE



                                                        select distinct city 
                                                        from station
                                                        where regexp_like(city, '^[^aeiouAEIOU]|*[^aeiouAEIOU]$');


                                                        In MySQL -



                                                         select distinct city 
                                                        from station
                                                        where city RLIKE '^[^aeiouAEIOU].*' OR
                                                        city RLIKE '^.*[^aeiouAEIOU]$';





                                                        share|improve this answer


























                                                          3












                                                          3








                                                          3






                                                          Query the list of CITY names from STATION that either do not start with vowels or do not end with vowels. IN ORACLE



                                                          select distinct city 
                                                          from station
                                                          where regexp_like(city, '^[^aeiouAEIOU]|*[^aeiouAEIOU]$');


                                                          In MySQL -



                                                           select distinct city 
                                                          from station
                                                          where city RLIKE '^[^aeiouAEIOU].*' OR
                                                          city RLIKE '^.*[^aeiouAEIOU]$';





                                                          share|improve this answer














                                                          Query the list of CITY names from STATION that either do not start with vowels or do not end with vowels. IN ORACLE



                                                          select distinct city 
                                                          from station
                                                          where regexp_like(city, '^[^aeiouAEIOU]|*[^aeiouAEIOU]$');


                                                          In MySQL -



                                                           select distinct city 
                                                          from station
                                                          where city RLIKE '^[^aeiouAEIOU].*' OR
                                                          city RLIKE '^.*[^aeiouAEIOU]$';






                                                          share|improve this answer














                                                          share|improve this answer



                                                          share|improve this answer








                                                          edited Aug 6 '18 at 18:00









                                                          Community

                                                          11




                                                          11










                                                          answered Feb 18 '18 at 18:45









                                                          Rahul YadavRahul Yadav

                                                          233




                                                          233























                                                              2














                                                              select distinct city from station 
                                                              where city Not like 'A%' and city Not like 'E%' and city Not like 'I%' and
                                                              city Not like 'o%' and city not like 'U%';





                                                              share|improve this answer




























                                                                2














                                                                select distinct city from station 
                                                                where city Not like 'A%' and city Not like 'E%' and city Not like 'I%' and
                                                                city Not like 'o%' and city not like 'U%';





                                                                share|improve this answer


























                                                                  2












                                                                  2








                                                                  2






                                                                  select distinct city from station 
                                                                  where city Not like 'A%' and city Not like 'E%' and city Not like 'I%' and
                                                                  city Not like 'o%' and city not like 'U%';





                                                                  share|improve this answer














                                                                  select distinct city from station 
                                                                  where city Not like 'A%' and city Not like 'E%' and city Not like 'I%' and
                                                                  city Not like 'o%' and city not like 'U%';






                                                                  share|improve this answer














                                                                  share|improve this answer



                                                                  share|improve this answer








                                                                  edited Jul 14 '16 at 12:41









                                                                  Bo Persson

                                                                  77.6k17116184




                                                                  77.6k17116184










                                                                  answered Jul 14 '16 at 9:58









                                                                  satishsatish

                                                                  211




                                                                  211























                                                                      1














                                                                      This worked on MS SQL SERVER:



                                                                      select distinct city from station where city NOT like '[aeuio]%' Order by City;





                                                                      share|improve this answer























                                                                      • it worked on MS SQL SERVER
                                                                        – abhinay vijay
                                                                        Dec 24 '16 at 8:41
















                                                                      1














                                                                      This worked on MS SQL SERVER:



                                                                      select distinct city from station where city NOT like '[aeuio]%' Order by City;





                                                                      share|improve this answer























                                                                      • it worked on MS SQL SERVER
                                                                        – abhinay vijay
                                                                        Dec 24 '16 at 8:41














                                                                      1












                                                                      1








                                                                      1






                                                                      This worked on MS SQL SERVER:



                                                                      select distinct city from station where city NOT like '[aeuio]%' Order by City;





                                                                      share|improve this answer














                                                                      This worked on MS SQL SERVER:



                                                                      select distinct city from station where city NOT like '[aeuio]%' Order by City;






                                                                      share|improve this answer














                                                                      share|improve this answer



                                                                      share|improve this answer








                                                                      edited Dec 24 '16 at 8:56









                                                                      FelixSFD

                                                                      4,27572986




                                                                      4,27572986










                                                                      answered Dec 24 '16 at 8:41









                                                                      abhinay vijayabhinay vijay

                                                                      311




                                                                      311












                                                                      • it worked on MS SQL SERVER
                                                                        – abhinay vijay
                                                                        Dec 24 '16 at 8:41


















                                                                      • it worked on MS SQL SERVER
                                                                        – abhinay vijay
                                                                        Dec 24 '16 at 8:41
















                                                                      it worked on MS SQL SERVER
                                                                      – abhinay vijay
                                                                      Dec 24 '16 at 8:41




                                                                      it worked on MS SQL SERVER
                                                                      – abhinay vijay
                                                                      Dec 24 '16 at 8:41











                                                                      1














                                                                      SELECT DISTINCT CITY from STATION  WHERE CITY RLIKE '^[^aeiouAEIOU].*$'





                                                                      share|improve this answer























                                                                      • This works for mysql
                                                                        – SunnyShineColorado
                                                                        Sep 16 '16 at 0:48
















                                                                      1














                                                                      SELECT DISTINCT CITY from STATION  WHERE CITY RLIKE '^[^aeiouAEIOU].*$'





                                                                      share|improve this answer























                                                                      • This works for mysql
                                                                        – SunnyShineColorado
                                                                        Sep 16 '16 at 0:48














                                                                      1












                                                                      1








                                                                      1






                                                                      SELECT DISTINCT CITY from STATION  WHERE CITY RLIKE '^[^aeiouAEIOU].*$'





                                                                      share|improve this answer














                                                                      SELECT DISTINCT CITY from STATION  WHERE CITY RLIKE '^[^aeiouAEIOU].*$'






                                                                      share|improve this answer














                                                                      share|improve this answer



                                                                      share|improve this answer








                                                                      edited Dec 24 '16 at 8:59









                                                                      Pang

                                                                      6,8911563101




                                                                      6,8911563101










                                                                      answered Sep 16 '16 at 0:47









                                                                      SunnyShineColoradoSunnyShineColorado

                                                                      111




                                                                      111












                                                                      • This works for mysql
                                                                        – SunnyShineColorado
                                                                        Sep 16 '16 at 0:48


















                                                                      • This works for mysql
                                                                        – SunnyShineColorado
                                                                        Sep 16 '16 at 0:48
















                                                                      This works for mysql
                                                                      – SunnyShineColorado
                                                                      Sep 16 '16 at 0:48




                                                                      This works for mysql
                                                                      – SunnyShineColorado
                                                                      Sep 16 '16 at 0:48











                                                                      1














                                                                      select distinct city from station where city regexp
                                                                      '^[^aeiou].*[^aeiou]$'


                                                                      If your query doesn't starts and ends with a vowel.






                                                                      share|improve this answer


























                                                                        1














                                                                        select distinct city from station where city regexp
                                                                        '^[^aeiou].*[^aeiou]$'


                                                                        If your query doesn't starts and ends with a vowel.






                                                                        share|improve this answer
























                                                                          1












                                                                          1








                                                                          1






                                                                          select distinct city from station where city regexp
                                                                          '^[^aeiou].*[^aeiou]$'


                                                                          If your query doesn't starts and ends with a vowel.






                                                                          share|improve this answer












                                                                          select distinct city from station where city regexp
                                                                          '^[^aeiou].*[^aeiou]$'


                                                                          If your query doesn't starts and ends with a vowel.







                                                                          share|improve this answer












                                                                          share|improve this answer



                                                                          share|improve this answer










                                                                          answered May 21 '17 at 16:42









                                                                          marwarimarwari

                                                                          587




                                                                          587























                                                                              1














                                                                              Try the following:



                                                                              SELECT DISTINCT CITY FROM STATION
                                                                              WHERE CITY REGEXP '^[^aeiou].*';


                                                                              MySQL Ref.: https://dev.mysql.com/doc/refman/5.5/en/regexp.html






                                                                              share|improve this answer




























                                                                                1














                                                                                Try the following:



                                                                                SELECT DISTINCT CITY FROM STATION
                                                                                WHERE CITY REGEXP '^[^aeiou].*';


                                                                                MySQL Ref.: https://dev.mysql.com/doc/refman/5.5/en/regexp.html






                                                                                share|improve this answer


























                                                                                  1












                                                                                  1








                                                                                  1






                                                                                  Try the following:



                                                                                  SELECT DISTINCT CITY FROM STATION
                                                                                  WHERE CITY REGEXP '^[^aeiou].*';


                                                                                  MySQL Ref.: https://dev.mysql.com/doc/refman/5.5/en/regexp.html






                                                                                  share|improve this answer














                                                                                  Try the following:



                                                                                  SELECT DISTINCT CITY FROM STATION
                                                                                  WHERE CITY REGEXP '^[^aeiou].*';


                                                                                  MySQL Ref.: https://dev.mysql.com/doc/refman/5.5/en/regexp.html







                                                                                  share|improve this answer














                                                                                  share|improve this answer



                                                                                  share|improve this answer








                                                                                  edited Feb 21 '18 at 17:59









                                                                                  Syed Aslam

                                                                                  7,62953153




                                                                                  7,62953153










                                                                                  answered Feb 21 '18 at 16:42









                                                                                  simran kumarisimran kumari

                                                                                  111




                                                                                  111























                                                                                      1














                                                                                      Simple example without regular expressions



                                                                                      SELECT DISTINCT 
                                                                                      City
                                                                                      FROM Station
                                                                                      WHERE LEFT(City, 1) NOT IN ("a", "e", "i", "o", "u");





                                                                                      share|improve this answer




























                                                                                        1














                                                                                        Simple example without regular expressions



                                                                                        SELECT DISTINCT 
                                                                                        City
                                                                                        FROM Station
                                                                                        WHERE LEFT(City, 1) NOT IN ("a", "e", "i", "o", "u");





                                                                                        share|improve this answer


























                                                                                          1












                                                                                          1








                                                                                          1






                                                                                          Simple example without regular expressions



                                                                                          SELECT DISTINCT 
                                                                                          City
                                                                                          FROM Station
                                                                                          WHERE LEFT(City, 1) NOT IN ("a", "e", "i", "o", "u");





                                                                                          share|improve this answer














                                                                                          Simple example without regular expressions



                                                                                          SELECT DISTINCT 
                                                                                          City
                                                                                          FROM Station
                                                                                          WHERE LEFT(City, 1) NOT IN ("a", "e", "i", "o", "u");






                                                                                          share|improve this answer














                                                                                          share|improve this answer



                                                                                          share|improve this answer








                                                                                          edited Nov 25 '18 at 3:55









                                                                                          digital.aaron

                                                                                          3,1341128




                                                                                          3,1341128










                                                                                          answered Sep 3 '18 at 11:04









                                                                                          ed lovejoyed lovejoy

                                                                                          111




                                                                                          111























                                                                                              1














                                                                                              I tried this.



                                                                                              select distinct city
                                                                                              from station
                                                                                              where substring(city,1,1) not in('A','E','I','O','U');





                                                                                              share|improve this answer




























                                                                                                1














                                                                                                I tried this.



                                                                                                select distinct city
                                                                                                from station
                                                                                                where substring(city,1,1) not in('A','E','I','O','U');





                                                                                                share|improve this answer


























                                                                                                  1












                                                                                                  1








                                                                                                  1






                                                                                                  I tried this.



                                                                                                  select distinct city
                                                                                                  from station
                                                                                                  where substring(city,1,1) not in('A','E','I','O','U');





                                                                                                  share|improve this answer














                                                                                                  I tried this.



                                                                                                  select distinct city
                                                                                                  from station
                                                                                                  where substring(city,1,1) not in('A','E','I','O','U');






                                                                                                  share|improve this answer














                                                                                                  share|improve this answer



                                                                                                  share|improve this answer








                                                                                                  edited Dec 5 '18 at 20:42









                                                                                                  John Montgomery

                                                                                                  2,44961937




                                                                                                  2,44961937










                                                                                                  answered Dec 5 '18 at 20:19









                                                                                                  Makhmud GalyMakhmud Galy

                                                                                                  112




                                                                                                  112























                                                                                                      0














                                                                                                      SELECT DISTINCT CITY FROM STATION 
                                                                                                      WHERE CITY RLIKE '^.*[bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ]$';





                                                                                                      share|improve this answer




























                                                                                                        0














                                                                                                        SELECT DISTINCT CITY FROM STATION 
                                                                                                        WHERE CITY RLIKE '^.*[bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ]$';





                                                                                                        share|improve this answer


























                                                                                                          0












                                                                                                          0








                                                                                                          0






                                                                                                          SELECT DISTINCT CITY FROM STATION 
                                                                                                          WHERE CITY RLIKE '^.*[bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ]$';





                                                                                                          share|improve this answer














                                                                                                          SELECT DISTINCT CITY FROM STATION 
                                                                                                          WHERE CITY RLIKE '^.*[bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ]$';






                                                                                                          share|improve this answer














                                                                                                          share|improve this answer



                                                                                                          share|improve this answer








                                                                                                          edited Dec 9 '16 at 17:25









                                                                                                          Paul Roub

                                                                                                          32.6k85773




                                                                                                          32.6k85773










                                                                                                          answered Dec 9 '16 at 17:16









                                                                                                          MANJUNATH KAMMARMANJUNATH KAMMAR

                                                                                                          1




                                                                                                          1























                                                                                                              0














                                                                                                              In MS SQL:



                                                                                                              Select DISTINCT CITY
                                                                                                              FROM
                                                                                                              STATION
                                                                                                              Where CITY NOT LIKE 'A%' AND CITY NOT LIKE 'E%' AND CITY NOT LIKE 'I%' AND CITY NOT LIKE 'O%' AND CITY NOT LIKE 'U%';





                                                                                                              share|improve this answer


























                                                                                                                0














                                                                                                                In MS SQL:



                                                                                                                Select DISTINCT CITY
                                                                                                                FROM
                                                                                                                STATION
                                                                                                                Where CITY NOT LIKE 'A%' AND CITY NOT LIKE 'E%' AND CITY NOT LIKE 'I%' AND CITY NOT LIKE 'O%' AND CITY NOT LIKE 'U%';





                                                                                                                share|improve this answer
























                                                                                                                  0












                                                                                                                  0








                                                                                                                  0






                                                                                                                  In MS SQL:



                                                                                                                  Select DISTINCT CITY
                                                                                                                  FROM
                                                                                                                  STATION
                                                                                                                  Where CITY NOT LIKE 'A%' AND CITY NOT LIKE 'E%' AND CITY NOT LIKE 'I%' AND CITY NOT LIKE 'O%' AND CITY NOT LIKE 'U%';





                                                                                                                  share|improve this answer












                                                                                                                  In MS SQL:



                                                                                                                  Select DISTINCT CITY
                                                                                                                  FROM
                                                                                                                  STATION
                                                                                                                  Where CITY NOT LIKE 'A%' AND CITY NOT LIKE 'E%' AND CITY NOT LIKE 'I%' AND CITY NOT LIKE 'O%' AND CITY NOT LIKE 'U%';






                                                                                                                  share|improve this answer












                                                                                                                  share|improve this answer



                                                                                                                  share|improve this answer










                                                                                                                  answered Jan 24 '17 at 23:59









                                                                                                                  KrishneilKrishneil

                                                                                                                  630816




                                                                                                                  630816























                                                                                                                      0














                                                                                                                      you can use
                                                                                                                      select distinct city from station where city not RLIKE '^[aeiouAEIOU].*'






                                                                                                                      share|improve this answer


























                                                                                                                        0














                                                                                                                        you can use
                                                                                                                        select distinct city from station where city not RLIKE '^[aeiouAEIOU].*'






                                                                                                                        share|improve this answer
























                                                                                                                          0












                                                                                                                          0








                                                                                                                          0






                                                                                                                          you can use
                                                                                                                          select distinct city from station where city not RLIKE '^[aeiouAEIOU].*'






                                                                                                                          share|improve this answer












                                                                                                                          you can use
                                                                                                                          select distinct city from station where city not RLIKE '^[aeiouAEIOU].*'







                                                                                                                          share|improve this answer












                                                                                                                          share|improve this answer



                                                                                                                          share|improve this answer










                                                                                                                          answered Mar 8 '17 at 4:33









                                                                                                                          Sajal SinghSajal Singh

                                                                                                                          146211




                                                                                                                          146211























                                                                                                                              0














                                                                                                                              select distinct CITY from STATION where left(CITY,1) not in ('a','e','i','o','u') or right(CITY,1) not in ('a','e','i','o','u');






                                                                                                                              share|improve this answer


























                                                                                                                                0














                                                                                                                                select distinct CITY from STATION where left(CITY,1) not in ('a','e','i','o','u') or right(CITY,1) not in ('a','e','i','o','u');






                                                                                                                                share|improve this answer
























                                                                                                                                  0












                                                                                                                                  0








                                                                                                                                  0






                                                                                                                                  select distinct CITY from STATION where left(CITY,1) not in ('a','e','i','o','u') or right(CITY,1) not in ('a','e','i','o','u');






                                                                                                                                  share|improve this answer












                                                                                                                                  select distinct CITY from STATION where left(CITY,1) not in ('a','e','i','o','u') or right(CITY,1) not in ('a','e','i','o','u');







                                                                                                                                  share|improve this answer












                                                                                                                                  share|improve this answer



                                                                                                                                  share|improve this answer










                                                                                                                                  answered Mar 8 '17 at 17:42









                                                                                                                                  MohitMohit

                                                                                                                                  571212




                                                                                                                                  571212























                                                                                                                                      0














                                                                                                                                      select DISTINCT CITY from STATION where CITY NOT LIKE '[a,e,i,o,u]%'






                                                                                                                                      share|improve this answer


























                                                                                                                                        0














                                                                                                                                        select DISTINCT CITY from STATION where CITY NOT LIKE '[a,e,i,o,u]%'






                                                                                                                                        share|improve this answer
























                                                                                                                                          0












                                                                                                                                          0








                                                                                                                                          0






                                                                                                                                          select DISTINCT CITY from STATION where CITY NOT LIKE '[a,e,i,o,u]%'






                                                                                                                                          share|improve this answer












                                                                                                                                          select DISTINCT CITY from STATION where CITY NOT LIKE '[a,e,i,o,u]%'







                                                                                                                                          share|improve this answer












                                                                                                                                          share|improve this answer



                                                                                                                                          share|improve this answer










                                                                                                                                          answered May 26 '17 at 10:14









                                                                                                                                          Aman VermaAman Verma

                                                                                                                                          614




                                                                                                                                          614























                                                                                                                                              0














                                                                                                                                              try this one




                                                                                                                                              SELECT DISTINCT CITY FROM STATION WHERE
                                                                                                                                              LOWER(SUBSTR(CITY,LENGTH(CITY),1)) IN ('a','e','i','o','u');







                                                                                                                                              share|improve this answer


























                                                                                                                                                0














                                                                                                                                                try this one




                                                                                                                                                SELECT DISTINCT CITY FROM STATION WHERE
                                                                                                                                                LOWER(SUBSTR(CITY,LENGTH(CITY),1)) IN ('a','e','i','o','u');







                                                                                                                                                share|improve this answer
























                                                                                                                                                  0












                                                                                                                                                  0








                                                                                                                                                  0






                                                                                                                                                  try this one




                                                                                                                                                  SELECT DISTINCT CITY FROM STATION WHERE
                                                                                                                                                  LOWER(SUBSTR(CITY,LENGTH(CITY),1)) IN ('a','e','i','o','u');







                                                                                                                                                  share|improve this answer












                                                                                                                                                  try this one




                                                                                                                                                  SELECT DISTINCT CITY FROM STATION WHERE
                                                                                                                                                  LOWER(SUBSTR(CITY,LENGTH(CITY),1)) IN ('a','e','i','o','u');








                                                                                                                                                  share|improve this answer












                                                                                                                                                  share|improve this answer



                                                                                                                                                  share|improve this answer










                                                                                                                                                  answered Oct 12 '17 at 11:12









                                                                                                                                                  Ganesh GiriGanesh Giri

                                                                                                                                                  1855




                                                                                                                                                  1855























                                                                                                                                                      0














                                                                                                                                                      Select Distinct City from Station where City Like '[^aeiou]%';


                                                                                                                                                      MS SQL Server Tested.






                                                                                                                                                      share|improve this answer




























                                                                                                                                                        0














                                                                                                                                                        Select Distinct City from Station where City Like '[^aeiou]%';


                                                                                                                                                        MS SQL Server Tested.






                                                                                                                                                        share|improve this answer


























                                                                                                                                                          0












                                                                                                                                                          0








                                                                                                                                                          0






                                                                                                                                                          Select Distinct City from Station where City Like '[^aeiou]%';


                                                                                                                                                          MS SQL Server Tested.






                                                                                                                                                          share|improve this answer














                                                                                                                                                          Select Distinct City from Station where City Like '[^aeiou]%';


                                                                                                                                                          MS SQL Server Tested.







                                                                                                                                                          share|improve this answer














                                                                                                                                                          share|improve this answer



                                                                                                                                                          share|improve this answer








                                                                                                                                                          edited Apr 5 '18 at 21:32









                                                                                                                                                          Jose Da Silva

                                                                                                                                                          2,08421026




                                                                                                                                                          2,08421026










                                                                                                                                                          answered Apr 5 '18 at 21:02









                                                                                                                                                          DarpanDarpan

                                                                                                                                                          1




                                                                                                                                                          1























                                                                                                                                                              0














                                                                                                                                                               SELECT DISTINCT city from STATION
                                                                                                                                                              WHERE city NOT LIKE "[aieuo]%[aieuo] [aieuo]%[aieuo]"
                                                                                                                                                              AND city NOT LIKE "[aieuo]%[aieuo]";


                                                                                                                                                              The first NOT LIKE means, that each word of the two-word city names doesn't start and end with vowels. The second NOT LIKE is for one-word city names.






                                                                                                                                                              share|improve this answer


























                                                                                                                                                                0














                                                                                                                                                                 SELECT DISTINCT city from STATION
                                                                                                                                                                WHERE city NOT LIKE "[aieuo]%[aieuo] [aieuo]%[aieuo]"
                                                                                                                                                                AND city NOT LIKE "[aieuo]%[aieuo]";


                                                                                                                                                                The first NOT LIKE means, that each word of the two-word city names doesn't start and end with vowels. The second NOT LIKE is for one-word city names.






                                                                                                                                                                share|improve this answer
























                                                                                                                                                                  0












                                                                                                                                                                  0








                                                                                                                                                                  0






                                                                                                                                                                   SELECT DISTINCT city from STATION
                                                                                                                                                                  WHERE city NOT LIKE "[aieuo]%[aieuo] [aieuo]%[aieuo]"
                                                                                                                                                                  AND city NOT LIKE "[aieuo]%[aieuo]";


                                                                                                                                                                  The first NOT LIKE means, that each word of the two-word city names doesn't start and end with vowels. The second NOT LIKE is for one-word city names.






                                                                                                                                                                  share|improve this answer












                                                                                                                                                                   SELECT DISTINCT city from STATION
                                                                                                                                                                  WHERE city NOT LIKE "[aieuo]%[aieuo] [aieuo]%[aieuo]"
                                                                                                                                                                  AND city NOT LIKE "[aieuo]%[aieuo]";


                                                                                                                                                                  The first NOT LIKE means, that each word of the two-word city names doesn't start and end with vowels. The second NOT LIKE is for one-word city names.







                                                                                                                                                                  share|improve this answer












                                                                                                                                                                  share|improve this answer



                                                                                                                                                                  share|improve this answer










                                                                                                                                                                  answered Sep 25 '18 at 20:05









                                                                                                                                                                  David OsipovDavid Osipov

                                                                                                                                                                  12




                                                                                                                                                                  12























                                                                                                                                                                      0














                                                                                                                                                                      select distinct city from station where (
                                                                                                                                                                      left(city,1) not in ('a','e','i','o','u')
                                                                                                                                                                      and
                                                                                                                                                                      right(city,1) not in ('a','e','i','o','u')
                                                                                                                                                                      );





                                                                                                                                                                      share|improve this answer



















                                                                                                                                                                      • 1




                                                                                                                                                                        PLease add some explanation why this code answers the question.
                                                                                                                                                                        – Hintham
                                                                                                                                                                        Oct 21 '18 at 9:34










                                                                                                                                                                      • Thank you for this code snippet, which might provide some limited, immediate help. A proper explanation would greatly improve its long-term value by showing why this is a good solution to the problem, and would make it more useful to future readers with other, similar questions. Please edit your answer to add some explanation, including the assumptions you've made.
                                                                                                                                                                        – FrankerZ
                                                                                                                                                                        Oct 21 '18 at 16:05
















                                                                                                                                                                      0














                                                                                                                                                                      select distinct city from station where (
                                                                                                                                                                      left(city,1) not in ('a','e','i','o','u')
                                                                                                                                                                      and
                                                                                                                                                                      right(city,1) not in ('a','e','i','o','u')
                                                                                                                                                                      );





                                                                                                                                                                      share|improve this answer



















                                                                                                                                                                      • 1




                                                                                                                                                                        PLease add some explanation why this code answers the question.
                                                                                                                                                                        – Hintham
                                                                                                                                                                        Oct 21 '18 at 9:34










                                                                                                                                                                      • Thank you for this code snippet, which might provide some limited, immediate help. A proper explanation would greatly improve its long-term value by showing why this is a good solution to the problem, and would make it more useful to future readers with other, similar questions. Please edit your answer to add some explanation, including the assumptions you've made.
                                                                                                                                                                        – FrankerZ
                                                                                                                                                                        Oct 21 '18 at 16:05














                                                                                                                                                                      0












                                                                                                                                                                      0








                                                                                                                                                                      0






                                                                                                                                                                      select distinct city from station where (
                                                                                                                                                                      left(city,1) not in ('a','e','i','o','u')
                                                                                                                                                                      and
                                                                                                                                                                      right(city,1) not in ('a','e','i','o','u')
                                                                                                                                                                      );





                                                                                                                                                                      share|improve this answer














                                                                                                                                                                      select distinct city from station where (
                                                                                                                                                                      left(city,1) not in ('a','e','i','o','u')
                                                                                                                                                                      and
                                                                                                                                                                      right(city,1) not in ('a','e','i','o','u')
                                                                                                                                                                      );






                                                                                                                                                                      share|improve this answer














                                                                                                                                                                      share|improve this answer



                                                                                                                                                                      share|improve this answer








                                                                                                                                                                      edited Oct 21 '18 at 9:49









                                                                                                                                                                      Mohammad

                                                                                                                                                                      15.4k123361




                                                                                                                                                                      15.4k123361










                                                                                                                                                                      answered Oct 21 '18 at 9:27









                                                                                                                                                                      Rohit RawatRohit Rawat

                                                                                                                                                                      1




                                                                                                                                                                      1








                                                                                                                                                                      • 1




                                                                                                                                                                        PLease add some explanation why this code answers the question.
                                                                                                                                                                        – Hintham
                                                                                                                                                                        Oct 21 '18 at 9:34










                                                                                                                                                                      • Thank you for this code snippet, which might provide some limited, immediate help. A proper explanation would greatly improve its long-term value by showing why this is a good solution to the problem, and would make it more useful to future readers with other, similar questions. Please edit your answer to add some explanation, including the assumptions you've made.
                                                                                                                                                                        – FrankerZ
                                                                                                                                                                        Oct 21 '18 at 16:05














                                                                                                                                                                      • 1




                                                                                                                                                                        PLease add some explanation why this code answers the question.
                                                                                                                                                                        – Hintham
                                                                                                                                                                        Oct 21 '18 at 9:34










                                                                                                                                                                      • Thank you for this code snippet, which might provide some limited, immediate help. A proper explanation would greatly improve its long-term value by showing why this is a good solution to the problem, and would make it more useful to future readers with other, similar questions. Please edit your answer to add some explanation, including the assumptions you've made.
                                                                                                                                                                        – FrankerZ
                                                                                                                                                                        Oct 21 '18 at 16:05








                                                                                                                                                                      1




                                                                                                                                                                      1




                                                                                                                                                                      PLease add some explanation why this code answers the question.
                                                                                                                                                                      – Hintham
                                                                                                                                                                      Oct 21 '18 at 9:34




                                                                                                                                                                      PLease add some explanation why this code answers the question.
                                                                                                                                                                      – Hintham
                                                                                                                                                                      Oct 21 '18 at 9:34












                                                                                                                                                                      Thank you for this code snippet, which might provide some limited, immediate help. A proper explanation would greatly improve its long-term value by showing why this is a good solution to the problem, and would make it more useful to future readers with other, similar questions. Please edit your answer to add some explanation, including the assumptions you've made.
                                                                                                                                                                      – FrankerZ
                                                                                                                                                                      Oct 21 '18 at 16:05




                                                                                                                                                                      Thank you for this code snippet, which might provide some limited, immediate help. A proper explanation would greatly improve its long-term value by showing why this is a good solution to the problem, and would make it more useful to future readers with other, similar questions. Please edit your answer to add some explanation, including the assumptions you've made.
                                                                                                                                                                      – FrankerZ
                                                                                                                                                                      Oct 21 '18 at 16:05











                                                                                                                                                                      0














                                                                                                                                                                      In ORACLE:



                                                                                                                                                                      select 
                                                                                                                                                                      distinct(city)
                                                                                                                                                                      from station
                                                                                                                                                                      where regexp_like (city, '^[^A|E|I|O|U](*)');


                                                                                                                                                                      There is no need to specify the ending letter in this solution. It's not called out for in the problem presented.






                                                                                                                                                                      share|improve this answer























                                                                                                                                                                      • Between the two carots ( ^^ ) and after the U, there should be [ ]. They didn't post for some reason.
                                                                                                                                                                        – Aaron W.
                                                                                                                                                                        Nov 19 '18 at 20:41
















                                                                                                                                                                      0














                                                                                                                                                                      In ORACLE:



                                                                                                                                                                      select 
                                                                                                                                                                      distinct(city)
                                                                                                                                                                      from station
                                                                                                                                                                      where regexp_like (city, '^[^A|E|I|O|U](*)');


                                                                                                                                                                      There is no need to specify the ending letter in this solution. It's not called out for in the problem presented.






                                                                                                                                                                      share|improve this answer























                                                                                                                                                                      • Between the two carots ( ^^ ) and after the U, there should be [ ]. They didn't post for some reason.
                                                                                                                                                                        – Aaron W.
                                                                                                                                                                        Nov 19 '18 at 20:41














                                                                                                                                                                      0












                                                                                                                                                                      0








                                                                                                                                                                      0






                                                                                                                                                                      In ORACLE:



                                                                                                                                                                      select 
                                                                                                                                                                      distinct(city)
                                                                                                                                                                      from station
                                                                                                                                                                      where regexp_like (city, '^[^A|E|I|O|U](*)');


                                                                                                                                                                      There is no need to specify the ending letter in this solution. It's not called out for in the problem presented.






                                                                                                                                                                      share|improve this answer














                                                                                                                                                                      In ORACLE:



                                                                                                                                                                      select 
                                                                                                                                                                      distinct(city)
                                                                                                                                                                      from station
                                                                                                                                                                      where regexp_like (city, '^[^A|E|I|O|U](*)');


                                                                                                                                                                      There is no need to specify the ending letter in this solution. It's not called out for in the problem presented.







                                                                                                                                                                      share|improve this answer














                                                                                                                                                                      share|improve this answer



                                                                                                                                                                      share|improve this answer








                                                                                                                                                                      edited Nov 19 '18 at 20:50









                                                                                                                                                                      Hossein Golshani

                                                                                                                                                                      2,05851023




                                                                                                                                                                      2,05851023










                                                                                                                                                                      answered Nov 19 '18 at 20:40









                                                                                                                                                                      Aaron W.Aaron W.

                                                                                                                                                                      1




                                                                                                                                                                      1












                                                                                                                                                                      • Between the two carots ( ^^ ) and after the U, there should be [ ]. They didn't post for some reason.
                                                                                                                                                                        – Aaron W.
                                                                                                                                                                        Nov 19 '18 at 20:41


















                                                                                                                                                                      • Between the two carots ( ^^ ) and after the U, there should be [ ]. They didn't post for some reason.
                                                                                                                                                                        – Aaron W.
                                                                                                                                                                        Nov 19 '18 at 20:41
















                                                                                                                                                                      Between the two carots ( ^^ ) and after the U, there should be [ ]. They didn't post for some reason.
                                                                                                                                                                      – Aaron W.
                                                                                                                                                                      Nov 19 '18 at 20:41




                                                                                                                                                                      Between the two carots ( ^^ ) and after the U, there should be [ ]. They didn't post for some reason.
                                                                                                                                                                      – Aaron W.
                                                                                                                                                                      Nov 19 '18 at 20:41











                                                                                                                                                                      0














                                                                                                                                                                      for oracle



                                                                                                                                                                      select distinct 
                                                                                                                                                                      city
                                                                                                                                                                      from station
                                                                                                                                                                      where regexp_like(city, '^[^aeiouAEIOU].*');





                                                                                                                                                                      share|improve this answer




























                                                                                                                                                                        0














                                                                                                                                                                        for oracle



                                                                                                                                                                        select distinct 
                                                                                                                                                                        city
                                                                                                                                                                        from station
                                                                                                                                                                        where regexp_like(city, '^[^aeiouAEIOU].*');





                                                                                                                                                                        share|improve this answer


























                                                                                                                                                                          0












                                                                                                                                                                          0








                                                                                                                                                                          0






                                                                                                                                                                          for oracle



                                                                                                                                                                          select distinct 
                                                                                                                                                                          city
                                                                                                                                                                          from station
                                                                                                                                                                          where regexp_like(city, '^[^aeiouAEIOU].*');





                                                                                                                                                                          share|improve this answer














                                                                                                                                                                          for oracle



                                                                                                                                                                          select distinct 
                                                                                                                                                                          city
                                                                                                                                                                          from station
                                                                                                                                                                          where regexp_like(city, '^[^aeiouAEIOU].*');






                                                                                                                                                                          share|improve this answer














                                                                                                                                                                          share|improve this answer



                                                                                                                                                                          share|improve this answer








                                                                                                                                                                          edited Nov 25 '18 at 3:56









                                                                                                                                                                          digital.aaron

                                                                                                                                                                          3,1341128




                                                                                                                                                                          3,1341128










                                                                                                                                                                          answered Apr 28 '18 at 19:47









                                                                                                                                                                          Rasim SENRasim SEN

                                                                                                                                                                          11




                                                                                                                                                                          11























                                                                                                                                                                              0














                                                                                                                                                                              select distinct city from station where city regexp '^[^aeiou].*[^aeiou]$'


                                                                                                                                                                              distinct: to avoid the duplication on the following column



                                                                                                                                                                              regexp: MySql function (regexp) to obtain Regular Expressions. expression starts with ^ and ends with $. In Oracle its regexp_like (city,'RegEx') Regular Expressions With Oracle Database.



                                                                                                                                                                              [^...] means any character NOT contain any of ...
                                                                                                                                                                              [^...]. means a single character NOT contain any of ...
                                                                                                                                                                              [^...].* means first character NOT contain any of ...
                                                                                                                                                                              [^...].*[^...] means first character NOT contains any of ... AND not ends with ...
                                                                                                                                                                              [^aeiou].*[^aeiou] mean the first character NOT starts with vowels AND not ends with vowels






                                                                                                                                                                              share|improve this answer























                                                                                                                                                                              • While this code may answer the question, providing additional context regarding how and why it solves the problem would improve the answer's long-term value.
                                                                                                                                                                                – Alexander
                                                                                                                                                                                Nov 25 '18 at 11:28
















                                                                                                                                                                              0














                                                                                                                                                                              select distinct city from station where city regexp '^[^aeiou].*[^aeiou]$'


                                                                                                                                                                              distinct: to avoid the duplication on the following column



                                                                                                                                                                              regexp: MySql function (regexp) to obtain Regular Expressions. expression starts with ^ and ends with $. In Oracle its regexp_like (city,'RegEx') Regular Expressions With Oracle Database.



                                                                                                                                                                              [^...] means any character NOT contain any of ...
                                                                                                                                                                              [^...]. means a single character NOT contain any of ...
                                                                                                                                                                              [^...].* means first character NOT contain any of ...
                                                                                                                                                                              [^...].*[^...] means first character NOT contains any of ... AND not ends with ...
                                                                                                                                                                              [^aeiou].*[^aeiou] mean the first character NOT starts with vowels AND not ends with vowels






                                                                                                                                                                              share|improve this answer























                                                                                                                                                                              • While this code may answer the question, providing additional context regarding how and why it solves the problem would improve the answer's long-term value.
                                                                                                                                                                                – Alexander
                                                                                                                                                                                Nov 25 '18 at 11:28














                                                                                                                                                                              0












                                                                                                                                                                              0








                                                                                                                                                                              0






                                                                                                                                                                              select distinct city from station where city regexp '^[^aeiou].*[^aeiou]$'


                                                                                                                                                                              distinct: to avoid the duplication on the following column



                                                                                                                                                                              regexp: MySql function (regexp) to obtain Regular Expressions. expression starts with ^ and ends with $. In Oracle its regexp_like (city,'RegEx') Regular Expressions With Oracle Database.



                                                                                                                                                                              [^...] means any character NOT contain any of ...
                                                                                                                                                                              [^...]. means a single character NOT contain any of ...
                                                                                                                                                                              [^...].* means first character NOT contain any of ...
                                                                                                                                                                              [^...].*[^...] means first character NOT contains any of ... AND not ends with ...
                                                                                                                                                                              [^aeiou].*[^aeiou] mean the first character NOT starts with vowels AND not ends with vowels






                                                                                                                                                                              share|improve this answer














                                                                                                                                                                              select distinct city from station where city regexp '^[^aeiou].*[^aeiou]$'


                                                                                                                                                                              distinct: to avoid the duplication on the following column



                                                                                                                                                                              regexp: MySql function (regexp) to obtain Regular Expressions. expression starts with ^ and ends with $. In Oracle its regexp_like (city,'RegEx') Regular Expressions With Oracle Database.



                                                                                                                                                                              [^...] means any character NOT contain any of ...
                                                                                                                                                                              [^...]. means a single character NOT contain any of ...
                                                                                                                                                                              [^...].* means first character NOT contain any of ...
                                                                                                                                                                              [^...].*[^...] means first character NOT contains any of ... AND not ends with ...
                                                                                                                                                                              [^aeiou].*[^aeiou] mean the first character NOT starts with vowels AND not ends with vowels







                                                                                                                                                                              share|improve this answer














                                                                                                                                                                              share|improve this answer



                                                                                                                                                                              share|improve this answer








                                                                                                                                                                              edited Nov 26 '18 at 3:09

























                                                                                                                                                                              answered Nov 25 '18 at 3:11









                                                                                                                                                                              JayJay

                                                                                                                                                                              31226




                                                                                                                                                                              31226












                                                                                                                                                                              • While this code may answer the question, providing additional context regarding how and why it solves the problem would improve the answer's long-term value.
                                                                                                                                                                                – Alexander
                                                                                                                                                                                Nov 25 '18 at 11:28


















                                                                                                                                                                              • While this code may answer the question, providing additional context regarding how and why it solves the problem would improve the answer's long-term value.
                                                                                                                                                                                – Alexander
                                                                                                                                                                                Nov 25 '18 at 11:28
















                                                                                                                                                                              While this code may answer the question, providing additional context regarding how and why it solves the problem would improve the answer's long-term value.
                                                                                                                                                                              – Alexander
                                                                                                                                                                              Nov 25 '18 at 11:28




                                                                                                                                                                              While this code may answer the question, providing additional context regarding how and why it solves the problem would improve the answer's long-term value.
                                                                                                                                                                              – Alexander
                                                                                                                                                                              Nov 25 '18 at 11:28











                                                                                                                                                                              0














                                                                                                                                                                              Mysql we can use this.



                                                                                                                                                                              select distinct city from station where city regexp '^[^aeiou].*';


                                                                                                                                                                              To Know More About MySQL Regular Expression



                                                                                                                                                                              For Oracle we can use



                                                                                                                                                                              select distinct(city) from station where regexp_like (city, '^[^AEIOU](*)');


                                                                                                                                                                              To Know More About Oracle Regular Expression



                                                                                                                                                                              For MS SQL Server



                                                                                                                                                                              select distinct city from station where city not like '[aeuio]%';





                                                                                                                                                                              share|improve this answer


























                                                                                                                                                                                0














                                                                                                                                                                                Mysql we can use this.



                                                                                                                                                                                select distinct city from station where city regexp '^[^aeiou].*';


                                                                                                                                                                                To Know More About MySQL Regular Expression



                                                                                                                                                                                For Oracle we can use



                                                                                                                                                                                select distinct(city) from station where regexp_like (city, '^[^AEIOU](*)');


                                                                                                                                                                                To Know More About Oracle Regular Expression



                                                                                                                                                                                For MS SQL Server



                                                                                                                                                                                select distinct city from station where city not like '[aeuio]%';





                                                                                                                                                                                share|improve this answer
























                                                                                                                                                                                  0












                                                                                                                                                                                  0








                                                                                                                                                                                  0






                                                                                                                                                                                  Mysql we can use this.



                                                                                                                                                                                  select distinct city from station where city regexp '^[^aeiou].*';


                                                                                                                                                                                  To Know More About MySQL Regular Expression



                                                                                                                                                                                  For Oracle we can use



                                                                                                                                                                                  select distinct(city) from station where regexp_like (city, '^[^AEIOU](*)');


                                                                                                                                                                                  To Know More About Oracle Regular Expression



                                                                                                                                                                                  For MS SQL Server



                                                                                                                                                                                  select distinct city from station where city not like '[aeuio]%';





                                                                                                                                                                                  share|improve this answer












                                                                                                                                                                                  Mysql we can use this.



                                                                                                                                                                                  select distinct city from station where city regexp '^[^aeiou].*';


                                                                                                                                                                                  To Know More About MySQL Regular Expression



                                                                                                                                                                                  For Oracle we can use



                                                                                                                                                                                  select distinct(city) from station where regexp_like (city, '^[^AEIOU](*)');


                                                                                                                                                                                  To Know More About Oracle Regular Expression



                                                                                                                                                                                  For MS SQL Server



                                                                                                                                                                                  select distinct city from station where city not like '[aeuio]%';






                                                                                                                                                                                  share|improve this answer












                                                                                                                                                                                  share|improve this answer



                                                                                                                                                                                  share|improve this answer










                                                                                                                                                                                  answered Nov 30 '18 at 4:22









                                                                                                                                                                                  Arun SolomonArun Solomon

                                                                                                                                                                                  112




                                                                                                                                                                                  112























                                                                                                                                                                                      -1














                                                                                                                                                                                      select distinct city from station where
                                                                                                                                                                                      city not in
                                                                                                                                                                                      (select distinct city from station where
                                                                                                                                                                                      (city like "A%" or
                                                                                                                                                                                      city like "E%" or
                                                                                                                                                                                      city like "I%" or
                                                                                                                                                                                      city like "O%" or
                                                                                                                                                                                      city like "U%"
                                                                                                                                                                                      ));


                                                                                                                                                                                      This will work i guess.






                                                                                                                                                                                      share|improve this answer























                                                                                                                                                                                      • please provide justification, why it will work.
                                                                                                                                                                                        – piyushj
                                                                                                                                                                                        Oct 18 '16 at 3:27
















                                                                                                                                                                                      -1














                                                                                                                                                                                      select distinct city from station where
                                                                                                                                                                                      city not in
                                                                                                                                                                                      (select distinct city from station where
                                                                                                                                                                                      (city like "A%" or
                                                                                                                                                                                      city like "E%" or
                                                                                                                                                                                      city like "I%" or
                                                                                                                                                                                      city like "O%" or
                                                                                                                                                                                      city like "U%"
                                                                                                                                                                                      ));


                                                                                                                                                                                      This will work i guess.






                                                                                                                                                                                      share|improve this answer























                                                                                                                                                                                      • please provide justification, why it will work.
                                                                                                                                                                                        – piyushj
                                                                                                                                                                                        Oct 18 '16 at 3:27














                                                                                                                                                                                      -1












                                                                                                                                                                                      -1








                                                                                                                                                                                      -1






                                                                                                                                                                                      select distinct city from station where
                                                                                                                                                                                      city not in
                                                                                                                                                                                      (select distinct city from station where
                                                                                                                                                                                      (city like "A%" or
                                                                                                                                                                                      city like "E%" or
                                                                                                                                                                                      city like "I%" or
                                                                                                                                                                                      city like "O%" or
                                                                                                                                                                                      city like "U%"
                                                                                                                                                                                      ));


                                                                                                                                                                                      This will work i guess.






                                                                                                                                                                                      share|improve this answer














                                                                                                                                                                                      select distinct city from station where
                                                                                                                                                                                      city not in
                                                                                                                                                                                      (select distinct city from station where
                                                                                                                                                                                      (city like "A%" or
                                                                                                                                                                                      city like "E%" or
                                                                                                                                                                                      city like "I%" or
                                                                                                                                                                                      city like "O%" or
                                                                                                                                                                                      city like "U%"
                                                                                                                                                                                      ));


                                                                                                                                                                                      This will work i guess.







                                                                                                                                                                                      share|improve this answer














                                                                                                                                                                                      share|improve this answer



                                                                                                                                                                                      share|improve this answer








                                                                                                                                                                                      edited Oct 18 '16 at 4:14









                                                                                                                                                                                      noufalcep

                                                                                                                                                                                      2,25982136




                                                                                                                                                                                      2,25982136










                                                                                                                                                                                      answered Oct 18 '16 at 3:04









                                                                                                                                                                                      Saikrishna SyamalaSaikrishna Syamala

                                                                                                                                                                                      1




                                                                                                                                                                                      1












                                                                                                                                                                                      • please provide justification, why it will work.
                                                                                                                                                                                        – piyushj
                                                                                                                                                                                        Oct 18 '16 at 3:27


















                                                                                                                                                                                      • please provide justification, why it will work.
                                                                                                                                                                                        – piyushj
                                                                                                                                                                                        Oct 18 '16 at 3:27
















                                                                                                                                                                                      please provide justification, why it will work.
                                                                                                                                                                                      – piyushj
                                                                                                                                                                                      Oct 18 '16 at 3:27




                                                                                                                                                                                      please provide justification, why it will work.
                                                                                                                                                                                      – piyushj
                                                                                                                                                                                      Oct 18 '16 at 3:27











                                                                                                                                                                                      -1














                                                                                                                                                                                      SELECT DISTINCT CITY
                                                                                                                                                                                      FROM STATION
                                                                                                                                                                                      WHERE CITY NOT RLIKE '[aeiouAEIOU]$'



                                                                                                                                                                                      This works for MYSQL






                                                                                                                                                                                      share|improve this answer





















                                                                                                                                                                                      • You've anchored the pattern to the end of the string, not the start. This gets you cities that DON'T end in a vowel, the opposite of what was asked. Try
                                                                                                                                                                                        – Paul Campbell
                                                                                                                                                                                        Dec 9 '17 at 11:11










                                                                                                                                                                                      • Try SELECT 'Aberdeen' NOT RLIKE '[aeiouAEIOU]$' and see what you get.
                                                                                                                                                                                        – Paul Campbell
                                                                                                                                                                                        Dec 9 '17 at 11:19
















                                                                                                                                                                                      -1














                                                                                                                                                                                      SELECT DISTINCT CITY
                                                                                                                                                                                      FROM STATION
                                                                                                                                                                                      WHERE CITY NOT RLIKE '[aeiouAEIOU]$'



                                                                                                                                                                                      This works for MYSQL






                                                                                                                                                                                      share|improve this answer





















                                                                                                                                                                                      • You've anchored the pattern to the end of the string, not the start. This gets you cities that DON'T end in a vowel, the opposite of what was asked. Try
                                                                                                                                                                                        – Paul Campbell
                                                                                                                                                                                        Dec 9 '17 at 11:11










                                                                                                                                                                                      • Try SELECT 'Aberdeen' NOT RLIKE '[aeiouAEIOU]$' and see what you get.
                                                                                                                                                                                        – Paul Campbell
                                                                                                                                                                                        Dec 9 '17 at 11:19














                                                                                                                                                                                      -1












                                                                                                                                                                                      -1








                                                                                                                                                                                      -1






                                                                                                                                                                                      SELECT DISTINCT CITY
                                                                                                                                                                                      FROM STATION
                                                                                                                                                                                      WHERE CITY NOT RLIKE '[aeiouAEIOU]$'



                                                                                                                                                                                      This works for MYSQL






                                                                                                                                                                                      share|improve this answer












                                                                                                                                                                                      SELECT DISTINCT CITY
                                                                                                                                                                                      FROM STATION
                                                                                                                                                                                      WHERE CITY NOT RLIKE '[aeiouAEIOU]$'



                                                                                                                                                                                      This works for MYSQL







                                                                                                                                                                                      share|improve this answer












                                                                                                                                                                                      share|improve this answer



                                                                                                                                                                                      share|improve this answer










                                                                                                                                                                                      answered Dec 9 '17 at 7:33









                                                                                                                                                                                      Vivek GhanchiVivek Ghanchi

                                                                                                                                                                                      236




                                                                                                                                                                                      236












                                                                                                                                                                                      • You've anchored the pattern to the end of the string, not the start. This gets you cities that DON'T end in a vowel, the opposite of what was asked. Try
                                                                                                                                                                                        – Paul Campbell
                                                                                                                                                                                        Dec 9 '17 at 11:11










                                                                                                                                                                                      • Try SELECT 'Aberdeen' NOT RLIKE '[aeiouAEIOU]$' and see what you get.
                                                                                                                                                                                        – Paul Campbell
                                                                                                                                                                                        Dec 9 '17 at 11:19


















                                                                                                                                                                                      • You've anchored the pattern to the end of the string, not the start. This gets you cities that DON'T end in a vowel, the opposite of what was asked. Try
                                                                                                                                                                                        – Paul Campbell
                                                                                                                                                                                        Dec 9 '17 at 11:11










                                                                                                                                                                                      • Try SELECT 'Aberdeen' NOT RLIKE '[aeiouAEIOU]$' and see what you get.
                                                                                                                                                                                        – Paul Campbell
                                                                                                                                                                                        Dec 9 '17 at 11:19
















                                                                                                                                                                                      You've anchored the pattern to the end of the string, not the start. This gets you cities that DON'T end in a vowel, the opposite of what was asked. Try
                                                                                                                                                                                      – Paul Campbell
                                                                                                                                                                                      Dec 9 '17 at 11:11




                                                                                                                                                                                      You've anchored the pattern to the end of the string, not the start. This gets you cities that DON'T end in a vowel, the opposite of what was asked. Try
                                                                                                                                                                                      – Paul Campbell
                                                                                                                                                                                      Dec 9 '17 at 11:11












                                                                                                                                                                                      Try SELECT 'Aberdeen' NOT RLIKE '[aeiouAEIOU]$' and see what you get.
                                                                                                                                                                                      – Paul Campbell
                                                                                                                                                                                      Dec 9 '17 at 11:19




                                                                                                                                                                                      Try SELECT 'Aberdeen' NOT RLIKE '[aeiouAEIOU]$' and see what you get.
                                                                                                                                                                                      – Paul Campbell
                                                                                                                                                                                      Dec 9 '17 at 11:19


















                                                                                                                                                                                      draft saved

                                                                                                                                                                                      draft discarded




















































                                                                                                                                                                                      Thanks for contributing an answer to Stack Overflow!


                                                                                                                                                                                      • Please be sure to answer the question. Provide details and share your research!

                                                                                                                                                                                      But avoid



                                                                                                                                                                                      • Asking for help, clarification, or responding to other answers.

                                                                                                                                                                                      • Making statements based on opinion; back them up with references or personal experience.


                                                                                                                                                                                      To learn more, see our tips on writing great answers.




                                                                                                                                                                                      draft saved


                                                                                                                                                                                      draft discarded














                                                                                                                                                                                      StackExchange.ready(
                                                                                                                                                                                      function () {
                                                                                                                                                                                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f36634742%2fsql-query-to-find-a-list-of-city-names-that-dont-start-with-vowels%23new-answer', 'question_page');
                                                                                                                                                                                      }
                                                                                                                                                                                      );

                                                                                                                                                                                      Post as a guest















                                                                                                                                                                                      Required, but never shown





















































                                                                                                                                                                                      Required, but never shown














                                                                                                                                                                                      Required, but never shown












                                                                                                                                                                                      Required, but never shown







                                                                                                                                                                                      Required, but never shown

































                                                                                                                                                                                      Required, but never shown














                                                                                                                                                                                      Required, but never shown












                                                                                                                                                                                      Required, but never shown







                                                                                                                                                                                      Required, but never shown







                                                                                                                                                                                      Popular posts from this blog

                                                                                                                                                                                      MongoDB - Not Authorized To Execute Command

                                                                                                                                                                                      Npm cannot find a required file even through it is in the searched directory

                                                                                                                                                                                      in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith