bool ReportPrinter
::chargeReport(const QDate &beginDate,
const QDate &endDate
){ const QString file=":/database/chargereport.sql";
if(!loadFile(file, &sql)) return false;
/* query.prepare(sql);
query.bindValue(":beginDate", beginDate);
query.bindValue(":endDate", endDate);*/
if(!query.exec(sql)){
QMessageBox::critical(0, qApp
->applicationName
(), query.
lastError().
text());
return false;
}
else while(query.next()){
qDebug()<<query.value(0)<<query.value(1)<<query.value(2)<<query.value(3);
}
return true;
}
bool ReportPrinter::chargeReport(const QDate &beginDate, const QDate &endDate){
const QString file=":/database/chargereport.sql";
QString sql;
if(!loadFile(file, &sql)) return false;
QSqlQuery query;
/* query.prepare(sql);
query.bindValue(":beginDate", beginDate);
query.bindValue(":endDate", endDate);*/
if(!query.exec(sql)){
QMessageBox::critical(0, qApp->applicationName(), query.lastError().text());
return false;
}
else while(query.next()){
qDebug()<<query.value(0)<<query.value(1)<<query.value(2)<<query.value(3);
}
return true;
}
To copy to clipboard, switch view to plain text mode
SELECT @m:=(
SELECT COUNT(cardid)
FROM `transactions`
WHERE
operation>=1000 AND
operation<2000 );
SELECT
@m:=@m+1 AS 'id',
t.date,
o.name,
t.amount
FROM `transactions` AS t
INNER JOIN `operations` AS o ON t.operation=o.id
WHERE
operation>=1000 && operation<2000
ORDER BY date;
SELECT @m:=(
SELECT COUNT(cardid)
FROM `transactions`
WHERE
operation>=1000 AND
operation<2000 );
SELECT
@m:=@m+1 AS 'id',
t.date,
o.name,
t.amount
FROM `transactions` AS t
INNER JOIN `operations` AS o ON t.operation=o.id
WHERE
operation>=1000 && operation<2000
ORDER BY date;
To copy to clipboard, switch view to plain text mode
It gives to me the result of the first SELECT. I need the the result of 2nd SELECT
Bookmarks