Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

216
Views
Strip word from mysql value

Looking to run a select query to filter products by size, however the column Product_Size has characters after the number, for example 'inches'. I have tried the below but it brings back no results.

SELECT * FROM `products` where Product_size BETWEEN '2 inches' AND '4.9 inches'

How do I strip the word 'inches' from the query?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

You can use replace()

  SELECT * FROM products 
  where Category_List =1 and Category_List_2=7 and 
  Designed_For_Who LIKE '%%' and (RRP between '0' and '100000') and 
  Product_size BETWEEN cast(replace('2 inches',' inches','') as int) AND 
  cast(replace('4.9 inches',' inches','') as int) 
  ORDER BY Name ASC
over 4 years ago · Santiago Trujillo Report

0

You must convert the strings to numeric values.
For your case this conversion can be done implicitly by adding 0:

SELECT * 
FROM `products` 
WHERE 
  Product_size LIKE '%inches'
  AND
  Product_size + 0 BETWEEN '2 inches' + 0 AND '4.9 inches' + 0

See a simplified demo.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!