Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Query in Query

    General and Desktop
    2
    2
    559
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Z
      Zarkon last edited by

      I have a select query

      @QSqlQuery q;
      QString queryString;

      queryString.sprintf("select Application_ID from Applications where Application_name = '%s' and Application_major = %d and Application_minor=%d", application_info.Application_name.toLocal8Bit().data(), application_info.Application_major, application_info.Application_minor);

      if (!q.prepare(queryString)) {
      qDebug() << "Database error prepare";
      qDebug() << q.lastError();
      return;
      }
      if (!q.exec()) {
      qDebug() << "Database error exec";
      qDebug() << q.lastError();
      return;
      }@

      Now I want to do an update query that makes use of this select query. Is there a way to make use of 'q'? Like

      QSqlQuery upd;

      UPDATE "whatever fields" where application_id is in "query above"

      1 Reply Last reply Reply Quote 0
      • T
        Tomme last edited by

        The Query language depends of you database.
        you can do :
        UPDATE "whartever fields" where application_id in (select...)

        I think the best way to do it, if you already have the query result is :
        UPDATE "whartever fields" where application_id in (id1, id2...)

        1 Reply Last reply Reply Quote 0
        • First post
          Last post