L
L
luque2015-12-28 15:37:12
MySQL
luque, 2015-12-28 15:37:12

How to get double digit items from Mysql database?

The task is to compare the variable (id) taken by the GET method from the address bar with the id of the goods in the table and display the id elements with a two-digit number, a three-digit number, etc. from the Mysql database.
How to make such requests?
The goal is to display similar products from the database by id
id of similar products, respectively, have their own identifier (1 group - two-digit, 2 - three-digit, etc.)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Ukolov, 2015-12-28
@luque

select * from tbl where length(id) = 3;

V
Vladimir Martyanov, 2015-12-28
@vilgeforce

If id is a number, then you can make the condition WHERE id < 10 (1 character), id >= 10 AND id < 100 (2 characters) and so on, for example.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question