QSqlQuery query; query.exec("INSERT INTO students (name, age, grade) VALUES ('John Doe', 20, A)");
QSqlQuery query; query.exec("UPDATE students SET grade = B WHERE name = 'John Doe'");
QSqlQuery query; query.exec("SELECT * FROM students WHERE grade = 'A'"); while(query.next()) { QString name = query.value(0).toString(); int age = query.value(1).toInt(); QString grade = query.value(2).toString(); qDebug() << name << age << grade; }In this example, records from the students table where the grade is A are being retrieved. The values for each retrieved record are being stored in local variables, and then outputted to the console using qDebug(). The QSqlQuery function is part of the Qt library, which is included in the Qt framework package.