Skip navigation
Currently Being Moderated

filtering search results

Mar 28, 2012 9:01 AM

I am working with php/Mysql and have a table that contains many orders and each order has a long serial number. We often only use the last 4 digits of the serial number when referring to an order. I want to know how to filter my query only by the last 4 digits of the serial number so the orders are easier to reference in our system. Any ideas of how to do this are appreciated. Thanks so much.

  • Currently Being Moderated
    Mar 28, 2012 11:22 AM   in reply to novembr1111

    You are not filtering, you are truncating:


    SELECT RIGHT (serial_number, 4) from MyTable

    Mark as:
  • Currently Being Moderated
    Mar 29, 2012 3:13 PM   in reply to novembr1111

    >Is it possible to use one of these functions to not only select

    >the last 4 digits as well as a single digit earlier in the serial number?


    No, but you just need to use the function (or two different functions) twice in your SQL SELECT.

    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points