Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Syntax SQLITE 2 tables not working

Syntax SQLITE 2 tables not working

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 910 Views 2 Watching
  • 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.
  • F Offline
    F Offline
    filipdns
    wrote on last edited by A Former User
    #1

    Hello, following SQLite tutorial, I can use 2 tables and add conditions but the condition is not accepted, why?
    here the syntax is accepted and it working without condition:

    function dbregistration()
    {
        var db = dbGetHandle()
        db.transaction(function (tx) {
            var results = tx.executeSql(
    'SELECT  * FROM table1_log,table2_log where table1_log.registration=table2_log.registration')
    

    but with the condition to filter for each registration I got message:
    Error: ambiguous column name: registration

    function dbregistration(Pregistration)
    {
        var db = dbGetHandle()
        db.transaction(function (tx) {
            var results = tx.executeSql(
    'SELECT  * FROM table1_log,table2_log where table1_log.registration=table2_log.registration and registration=?'[Pregistration])
    

    Thank you for your help ;-)

    K 1 Reply Last reply
    0
    • F filipdns

      Hello, following SQLite tutorial, I can use 2 tables and add conditions but the condition is not accepted, why?
      here the syntax is accepted and it working without condition:

      function dbregistration()
      {
          var db = dbGetHandle()
          db.transaction(function (tx) {
              var results = tx.executeSql(
      'SELECT  * FROM table1_log,table2_log where table1_log.registration=table2_log.registration')
      

      but with the condition to filter for each registration I got message:
      Error: ambiguous column name: registration

      function dbregistration(Pregistration)
      {
          var db = dbGetHandle()
          db.transaction(function (tx) {
              var results = tx.executeSql(
      'SELECT  * FROM table1_log,table2_log where table1_log.registration=table2_log.registration and registration=?'[Pregistration])
      

      Thank you for your help ;-)

      K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      @filipdns

      What programming language are you using?
      Where is the relation to Qt?

      @filipdns said in syntax SQLITE 2 tables not working in QT, why?:

      function dbregistration(Pregistration)
      {
          var db = dbGetHandle()
          db.transaction(function (tx) {
              var results = tx.executeSql(
      'SELECT  * FROM table1_log,table2_log where table1_log.registration=table2_log.registration and registration=?'[Pregistration])
      

      This syntax looks like using an array. But using an index for a constant string does not make sense.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      2
      • F Offline
        F Offline
        filipdns
        wrote on last edited by filipdns
        #3

        In first I'm using qml and JS for queries.

        What I want to do is :
        2 tables,
        table2 had only 1 row for each registration.
        when new entry is done in table1, a value of column2 of table1 increase a value of column3 of table2 (table1.column2 + table2.column3=new value of table2.column3)
        the common column of both tables is registration
        but in tableview qml, I want to show only values of one registration following data (Pregistration) from stackview .

        the relation with QT and *.js is just I supposed I have do make other syntax than SQLite page say because I found tutorial with the "word" AND + conditions but I'm unable to make it working.

        here what I found on SQLite page:

        
        SELECT CLI_NAME, MOB_NUMBER
        FROM T_CUSTOMER C, T_PHONE T
        WHERE C.CLI_ID = T.CLI_ID
          AND TYP_CODE = 'FAX'
        
        K 1 Reply Last reply
        0
        • F filipdns

          In first I'm using qml and JS for queries.

          What I want to do is :
          2 tables,
          table2 had only 1 row for each registration.
          when new entry is done in table1, a value of column2 of table1 increase a value of column3 of table2 (table1.column2 + table2.column3=new value of table2.column3)
          the common column of both tables is registration
          but in tableview qml, I want to show only values of one registration following data (Pregistration) from stackview .

          the relation with QT and *.js is just I supposed I have do make other syntax than SQLite page say because I found tutorial with the "word" AND + conditions but I'm unable to make it working.

          here what I found on SQLite page:

          
          SELECT CLI_NAME, MOB_NUMBER
          FROM T_CUSTOMER C, T_PHONE T
          WHERE C.CLI_ID = T.CLI_ID
            AND TYP_CODE = 'FAX'
          
          K Offline
          K Offline
          koahnig
          wrote on last edited by
          #4

          @filipdns

          I am not a QSQL expert, but to my understanding all SQL key words shall be in capital. Also basically it is part of the SQL driver to translate the commands and to execute. Therefore, you need pay attention to the respective syntax of the driver you are using.

          Vote the answer(s) that helped you to solve your issue(s)

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved