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

filtering search results

New Here ,
Mar 28, 2012 Mar 28, 2012

Copy link to clipboard

Copied

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

Views

487
Translate

Report

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

Copy link to clipboard

Copied

You are not filtering, you are truncating:

SELECT RIGHT (serial_number, 4) from MyTable

Votes

Translate

Report

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

Copy link to clipboard

Copied

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.

Votes

Translate

Report

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

Copy link to clipboard

Copied

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.

Votes

Translate

Report

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