samedi 20 février 2016

Unable to execute statement QSqlError

I have 3 tables:

enter image description here

I wanted to select orders (names and prices of services) ordered by the user of the given ID. I'm using sqlite.

My query looks like this:

    QSqlQuery query;
    QString queryStr = "SELECT NAME, PRICE FROM SERVICE "
                       "JOIN ORDERS "
                       "ON ORDERS.SERVICE_ID = SERVICE.ID "
                       "JOIN USERS "
                       "ON ORDERS.USER_ID = USERS.ID "
                       "WHERE USERS.ID=" + user_id + ";";

However, it gives me errors:

QSqlError("1", "Unable to execute statement", "near \"queryStr\": syntax error")

Aucun commentaire:

Enregistrer un commentaire