Answer the question
In order to leave comments, you need to log in
How to insert data from QtableView into sql query?
Hello, there is a tableView in it, one column in which you can add values, you need to execute the following request by clicking on the button:
SELECT reservtable.sudovlad, reservtable.summa, reservtable.years, reservtable2.summa2, reservtable2.years2
FROM(
SELECT sudovlad, Sum(gruz_pass) AS summa, Extract(YEAR from data_vih_p_ot ) AS years
FROM ships WHERE sudovlad = 'pere'
GROUP by Extract(YEAR from data_vih_p_ot )
) reservtable,
(SELECT sudovlad, Sum(gruz_pass) AS summa2, Extract(YEAR from data_vih_p_ot ) AS years2
FROM ships WHERE sudovlad = 'pere'
GROUP by Extract(YEAR from data_vih_p_ot )
) reservtable2
WHERE reservtable.years=2018 AND reservtable2.years2=2017
Answer the question
In order to leave comments, you need to log in
void currencysViewDialog::getCurrenciesID(){
QModelIndex currensyIndex = ui->currenciesTableView->currentIndex();
int selectedRow = currensyIndex.row();
int selectedColumn = 0;
currensyCurrentID =ui->currenciesTableView->model()->data(ui->currenciesTableView->model()->index(selectedRow,selectedColumn)).toInt();
qDebug() << trUtf8("Current ID:") << currensyCurrentID;
}
void currencysViewDialog::currensiesModify(){
getCurrenciesID();
QSqlQuery *getCurrencies = new QSqlQuery;
getCurrencies->prepare("SELECT "
"currency_id, "
"currency_name, "
"currency_altname, "
"currency_rate, "
"currency_national, "
"currency_code "
"FROM "
"currencies "
"WHERE "
"deleted='false' "
"AND currency_id=:currensyCurrentID");
getCurrencies->bindValue(":currensyCurrentID",currensyCurrentID);
getCurrencies->exec();
// if(getCurrencies->lastError().isValid())
qDebug() << trUtf8("Запрос:") << getCurrencies->executedQuery();
qDebug() << trUtf8("Error:") << getCurrencies->lastError();
while(getCurrencies->next()){
currensyID = getCurrencies->value(0).toInt();
currensyName = getCurrencies->value(1).toString();
currensAltName = getCurrencies->value(2).toString();
currensyRate = getCurrencies->value(3).toDouble();
currensyNational = getCurrencies->value(4).toBool();
currensyCode = getCurrencies->value(5).toInt();
qDebug() << trUtf8("ID:") << currensyID;
qDebug() << trUtf8("Имя валюты:") << currensyName;
qDebug() << trUtf8("AltName:") << currensAltName;
qDebug() << trUtf8("Rate:") << currensyRate;
qDebug() << trUtf8("National:") << currensyNational;
qDebug() << trUtf8("Code:") << currensyCode;
}
currencysChangeDialog dialog(this);
dialog.currensiesEdit(currensyID,currensyName,currensAltName,currensyRate,currensyNational,currensyCode);
dialog.exec();
if(dialog.close())
getCurrenciesList();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question