Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

filtering search results

New Here ,
Mar 28, 2012 Mar 28, 2012

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.

TOPICS
Server side applications
514
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 28, 2012 Mar 28, 2012

You are not filtering, you are truncating:

SELECT RIGHT (serial_number, 4) from MyTable

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 29, 2012 Mar 29, 2012

Thanks a lot. Works great. I also used SELECT MID() and that worked as well. 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? Thanks a lot for your help.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 29, 2012 Mar 29, 2012
LATEST

>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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines