Answer the question
In order to leave comments, you need to log in
How to search by number in database?
Hello.
I need to make a search query for all fields in the table, but I ran into a search by numbers. The point is that when you enter a number, records are displayed where this number occurs. Similar to LIKE, but this operator does not work for numbers. We knock out an error that it is impossible to apply for the integer type.
with DataModule2.ADOQuery1 do
begin
SQL.Clear;
SQL.Add('SELECT i.*, p.name AS name_prod, f_t.name AS furn_type');
SQL.Add('FROM items as i ');
SQL.Add('JOIN producers as p ON i.producer_id = p.id_producer');
SQL.Add('JOIN furniture_type as f_t ON i.furniture_type_id = f_t.id_furniture');
SQL.Add('WHERE UPPER(i.name) LIKE upper(''%' + search.Text + '%'')' + ' OR ');
SQL.Add('UPPER(p.name) LIKE upper(''%' + search.Text + '%'')' + ' OR ');
SQL.Add('UPPER(f_t.name) LIKE upper(''%' + search.Text + '%'')' + ' OR ');
Open;
end;
Answer the question
In order to leave comments, you need to log in
you can fool around somehow so
you can immediately keep the prices in varchar and compare more less by multiplying - this is easier than the reverse envelope
where (a * 1)> 10
but in general - if you have such a question with numbers and prices - something is wrong so you do (no offense - in an idiotic way), or you set the task the wrong way, or you solve it wrong
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question