You execute a query looking for the record and see if it returns any rows. There is nothing Qt-specific about this.
bool ok;
bool foundBoth = false;
ok = q.exec("select 1 from table1 where field = value");
if (ok && q.next()) {
ok = q.exec("select 1 from table2 where field = value");
if (ok && q.next()) {
foundBoth = true;
}
}
bool ok;
bool foundBoth = false;
QSqlQuery q;
ok = q.exec("select 1 from table1 where field = value");
if (ok && q.next()) {
ok = q.exec("select 1 from table2 where field = value");
if (ok && q.next()) {
foundBoth = true;
}
}
To copy to clipboard, switch view to plain text mode
Use bound parameters if there is any chance the value can be supplied directly by the user or contain semicolons, quotes etc. Heck, just use bound parameters anyway.
Bookmarks