how to retrieve records from table which starts with a numerical value in mysql ?

4 replies
Hello,

I need to know that how can we retrieve those records start with a numerical value or digit from a table in mysql database ??
#mysql #numerical #records #retrieve #starts #table
  • Profile picture of the author webpro4hire
    Try this:

    Code:
    SELECT * FROM table WHERE search_field RLIKE '[0-9]%'
    not tested tho, depends on many factors such as your MySQL Version, field definition..

    Good luck,
    WP4H
    {{ DiscussionBoard.errors[3177290].message }}
    • Profile picture of the author Jilawatan
      Hey Thanks,

      I also got this mysql statement which has been tested:


      PHP Code:
      SELECT col_1 FROM table1 WHERE col_1 REGEXP '[0-9]%' 


      Thanks anyway for adding another trick in my mind
      {{ DiscussionBoard.errors[3179929].message }}
  • Profile picture of the author AndyBlackSEO
    If you are wanting to get all the records but the ones starting with numbers first, then I'm pretty sure you can just use.. SELECT * FROM table ORDER BY fieldname ASC

    It will order by numberical and then by alphabet.
    Signature
    [FREE SEO TOOL] Build 29 Effective, High Authority Backlinks that Will Increase Your Google Rankings in 2020... CLICK HERE ...
    ... Instant backlinks that can get you results within 24-72hrs.
    {{ DiscussionBoard.errors[3180397].message }}
  • Profile picture of the author Jilawatan
    Andy.. I was just trying to get only those records which are starting with a numerical value. Not for the alphabets
    {{ DiscussionBoard.errors[3180487].message }}

Trending Topics