MySQL select from text column with specification











up vote
1
down vote

favorite












I would like to query a database which is MySQL 5.



Let's say database name is db and the table name is table and the column name is column



and that column is a text



containing the following for example:



aksksksksjsjk&ct=100&lor=10
aksksksksjsjk&ct=1001001001001001&lor=10


So i would like to query that table and grep only where ct start with number 1 and it's 16 numbers.



I tried with SELECT column FROM db.table WHERE column LIKE '%ct=1%'



so it's gonna grep where ct start with number 1



so kindly try to help me to proceed with select ct when start with number 1 and contain 16 numbers










share|improve this question







New contributor




Doumer Issac is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
























    up vote
    1
    down vote

    favorite












    I would like to query a database which is MySQL 5.



    Let's say database name is db and the table name is table and the column name is column



    and that column is a text



    containing the following for example:



    aksksksksjsjk&ct=100&lor=10
    aksksksksjsjk&ct=1001001001001001&lor=10


    So i would like to query that table and grep only where ct start with number 1 and it's 16 numbers.



    I tried with SELECT column FROM db.table WHERE column LIKE '%ct=1%'



    so it's gonna grep where ct start with number 1



    so kindly try to help me to proceed with select ct when start with number 1 and contain 16 numbers










    share|improve this question







    New contributor




    Doumer Issac is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.






















      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I would like to query a database which is MySQL 5.



      Let's say database name is db and the table name is table and the column name is column



      and that column is a text



      containing the following for example:



      aksksksksjsjk&ct=100&lor=10
      aksksksksjsjk&ct=1001001001001001&lor=10


      So i would like to query that table and grep only where ct start with number 1 and it's 16 numbers.



      I tried with SELECT column FROM db.table WHERE column LIKE '%ct=1%'



      so it's gonna grep where ct start with number 1



      so kindly try to help me to proceed with select ct when start with number 1 and contain 16 numbers










      share|improve this question







      New contributor




      Doumer Issac is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      I would like to query a database which is MySQL 5.



      Let's say database name is db and the table name is table and the column name is column



      and that column is a text



      containing the following for example:



      aksksksksjsjk&ct=100&lor=10
      aksksksksjsjk&ct=1001001001001001&lor=10


      So i would like to query that table and grep only where ct start with number 1 and it's 16 numbers.



      I tried with SELECT column FROM db.table WHERE column LIKE '%ct=1%'



      so it's gonna grep where ct start with number 1



      so kindly try to help me to proceed with select ct when start with number 1 and contain 16 numbers







      mysql sql regex






      share|improve this question







      New contributor




      Doumer Issac is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      Doumer Issac is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      Doumer Issac is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 2 days ago









      Doumer Issac

      82




      82




      New contributor




      Doumer Issac is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Doumer Issac is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Doumer Issac is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          In its basic form, you might want to use



          SELECT column FROM db.table WHERE column REGEXP BINARY 'ct=1[0-9]{15}'


          Or, to match as a whole word:



          SELECT column FROM db.table WHERE column REGEXP BINARY '[[:<:]]ct=1[0-9]{15}[[:>:]]'


          Note that [0-9]{15} matches 15 digits.



          The BINARY keyword will make matching case sensitive, so only ct will get matched and CT won't. Remove it if you need to keep the regex case insensitive.



          The [[:<:]] matches the left-hand (starting) word boundary and [[:>:]] matches the trailing (end) word boundary.






          share|improve this answer





















          • Thank you so much. it's work. mind if i asked you another question? in case if the same text include exp=0918 so are there's way to select exp bigger than 0918 ?
            – Doumer Issac
            2 days ago










          • @DoumerIssac That is a complex topic. However, using the number range generator, you may try 0*(919|9[2-9][0-9]|[1-9][0-9]{3,})
            – Wiktor Stribiżew
            2 days ago













          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',
          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
          });


          }
          });






          Doumer Issac is a new contributor. Be nice, and check out our Code of Conduct.










           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53203943%2fmysql-select-from-text-column-with-specification%23new-answer', 'question_page');
          }
          );

          Post as a guest
































          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          1
          down vote



          accepted










          In its basic form, you might want to use



          SELECT column FROM db.table WHERE column REGEXP BINARY 'ct=1[0-9]{15}'


          Or, to match as a whole word:



          SELECT column FROM db.table WHERE column REGEXP BINARY '[[:<:]]ct=1[0-9]{15}[[:>:]]'


          Note that [0-9]{15} matches 15 digits.



          The BINARY keyword will make matching case sensitive, so only ct will get matched and CT won't. Remove it if you need to keep the regex case insensitive.



          The [[:<:]] matches the left-hand (starting) word boundary and [[:>:]] matches the trailing (end) word boundary.






          share|improve this answer





















          • Thank you so much. it's work. mind if i asked you another question? in case if the same text include exp=0918 so are there's way to select exp bigger than 0918 ?
            – Doumer Issac
            2 days ago










          • @DoumerIssac That is a complex topic. However, using the number range generator, you may try 0*(919|9[2-9][0-9]|[1-9][0-9]{3,})
            – Wiktor Stribiżew
            2 days ago

















          up vote
          1
          down vote



          accepted










          In its basic form, you might want to use



          SELECT column FROM db.table WHERE column REGEXP BINARY 'ct=1[0-9]{15}'


          Or, to match as a whole word:



          SELECT column FROM db.table WHERE column REGEXP BINARY '[[:<:]]ct=1[0-9]{15}[[:>:]]'


          Note that [0-9]{15} matches 15 digits.



          The BINARY keyword will make matching case sensitive, so only ct will get matched and CT won't. Remove it if you need to keep the regex case insensitive.



          The [[:<:]] matches the left-hand (starting) word boundary and [[:>:]] matches the trailing (end) word boundary.






          share|improve this answer





















          • Thank you so much. it's work. mind if i asked you another question? in case if the same text include exp=0918 so are there's way to select exp bigger than 0918 ?
            – Doumer Issac
            2 days ago










          • @DoumerIssac That is a complex topic. However, using the number range generator, you may try 0*(919|9[2-9][0-9]|[1-9][0-9]{3,})
            – Wiktor Stribiżew
            2 days ago















          up vote
          1
          down vote



          accepted







          up vote
          1
          down vote



          accepted






          In its basic form, you might want to use



          SELECT column FROM db.table WHERE column REGEXP BINARY 'ct=1[0-9]{15}'


          Or, to match as a whole word:



          SELECT column FROM db.table WHERE column REGEXP BINARY '[[:<:]]ct=1[0-9]{15}[[:>:]]'


          Note that [0-9]{15} matches 15 digits.



          The BINARY keyword will make matching case sensitive, so only ct will get matched and CT won't. Remove it if you need to keep the regex case insensitive.



          The [[:<:]] matches the left-hand (starting) word boundary and [[:>:]] matches the trailing (end) word boundary.






          share|improve this answer












          In its basic form, you might want to use



          SELECT column FROM db.table WHERE column REGEXP BINARY 'ct=1[0-9]{15}'


          Or, to match as a whole word:



          SELECT column FROM db.table WHERE column REGEXP BINARY '[[:<:]]ct=1[0-9]{15}[[:>:]]'


          Note that [0-9]{15} matches 15 digits.



          The BINARY keyword will make matching case sensitive, so only ct will get matched and CT won't. Remove it if you need to keep the regex case insensitive.



          The [[:<:]] matches the left-hand (starting) word boundary and [[:>:]] matches the trailing (end) word boundary.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 2 days ago









          Wiktor Stribiżew

          298k16119193




          298k16119193












          • Thank you so much. it's work. mind if i asked you another question? in case if the same text include exp=0918 so are there's way to select exp bigger than 0918 ?
            – Doumer Issac
            2 days ago










          • @DoumerIssac That is a complex topic. However, using the number range generator, you may try 0*(919|9[2-9][0-9]|[1-9][0-9]{3,})
            – Wiktor Stribiżew
            2 days ago




















          • Thank you so much. it's work. mind if i asked you another question? in case if the same text include exp=0918 so are there's way to select exp bigger than 0918 ?
            – Doumer Issac
            2 days ago










          • @DoumerIssac That is a complex topic. However, using the number range generator, you may try 0*(919|9[2-9][0-9]|[1-9][0-9]{3,})
            – Wiktor Stribiżew
            2 days ago


















          Thank you so much. it's work. mind if i asked you another question? in case if the same text include exp=0918 so are there's way to select exp bigger than 0918 ?
          – Doumer Issac
          2 days ago




          Thank you so much. it's work. mind if i asked you another question? in case if the same text include exp=0918 so are there's way to select exp bigger than 0918 ?
          – Doumer Issac
          2 days ago












          @DoumerIssac That is a complex topic. However, using the number range generator, you may try 0*(919|9[2-9][0-9]|[1-9][0-9]{3,})
          – Wiktor Stribiżew
          2 days ago






          @DoumerIssac That is a complex topic. However, using the number range generator, you may try 0*(919|9[2-9][0-9]|[1-9][0-9]{3,})
          – Wiktor Stribiżew
          2 days ago












          Doumer Issac is a new contributor. Be nice, and check out our Code of Conduct.










           

          draft saved


          draft discarded


















          Doumer Issac is a new contributor. Be nice, and check out our Code of Conduct.













          Doumer Issac is a new contributor. Be nice, and check out our Code of Conduct.












          Doumer Issac is a new contributor. Be nice, and check out our Code of Conduct.















           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53203943%2fmysql-select-from-text-column-with-specification%23new-answer', 'question_page');
          }
          );

          Post as a guest




















































































          Popular posts from this blog

          Schultheiß

          Liste der Kulturdenkmale in Wilsdruff

          Android Play Services Check