A
A
animr2014-12-19 17:46:47
MySQL
animr, 2014-12-19 17:46:47

How to determine if a record exists in a MySQL database?

Why is 1 returned to me, although there are no records in the database on request? The code is:
querySQL := 'SELECT COUNT(*) `article` FROM `sdvd_products` WHERE `article` = "'+article+'"';
qQuery.SQL.Clear;
uti := qQuery.SQL.Add(querySQL);
if uti = 0 then
ShowMessage('The specified entry '+article+' does not exist!')
else
begin
qQuery.SQL.Clear;
qQuery.SQL.Add('UPDATE `sdvd_products` SET `price` = :_price WHERE `article` = "'+article+'"');
qQuery.ParamByName('_price').Value := price;
qQuery.ExecSQL;
end;
what's wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
ldv, 2014-12-19
@animr

uti := qQuery.SQL.Add(querySQL);
this is not a request

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question