I tried
QSqlQuery query; query.prepare("DELETE FROM names WHERE id_col = :ID OR id_parent = :ID"); query.bindValue(":ID", idVal); query.exec();
assuming idVal will be bound twice, but when this request is executed, only rows with id_parent = idVal are deleted, while id_col = idVal remains undeleted. Thus, only the second idVal was bound to the request.
When I rewrite it to
QSqlQuery query; query.prepare("DELETE FROM names WHERE id_col = ? OR id_parent = ?"); query.bindValue(0, idVal); query.bindValue(1, idVal); query.exec();
everything worked as expected.
Is it possible to use the same placeholder name multiple times in QSqlQuery?
source share