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. SQLQuery Like problem
Forum Update on Monday, May 27th 2025

SQLQuery Like problem

Scheduled Pinned Locked Moved Solved General and Desktop
qsqlquerybinding
3 Posts 2 Posters 641 Views
  • 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.
  • G Offline
    G Offline
    gaab
    wrote on 10 Mar 2019, 19:00 last edited by gaab 3 Oct 2019, 19:05
    #1

    The following query give the expected result from DBBrowser for SQLite

    select ident, name, laty, lonx, state, country from airport where scenery_local_path like '%FOLDER NAME%' order by country, state ;
    

    With QT SQLQuery and C++, the following code

    quAddOns->prepare("select ident, name, laty, lonx, state, country from airport  where scenery_local_path like :AddOn order by :Sort ;")
    
     quAddOns->bindValue(":AddOn", "%FOLDER NAME%");
     quAddOns->bindValue(":Sort", "country, state" );
    
     quAddOns-exec();
    

    gives the correct number of result but don't sort !
    If I modify (without the :Sort bind value)

    quAddOns->prepare("select ident, name, laty, lonx, state, country from airport  where scenery_local_path like :AddOn order by country, state")
    

    gives the expected sorted results !

    If I try to insert single quote (as with DB Browser) or double quote, either inside the prepare string or in the value to bind, the result exec() is empty (but no error).

    I don't understand what I am doing wrong :(
    Suggestions are VERY welcome...

    Thanks

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 10 Mar 2019, 19:07 last edited by
      #2

      Hi and welcome to devnet,

      To the best of my knowledge, bind parameters doesn't apply to elements of the query like sort.

      That one you'll have to build the string with it.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      G 1 Reply Last reply 10 Mar 2019, 19:13
      1
      • S SGaist
        10 Mar 2019, 19:07

        Hi and welcome to devnet,

        To the best of my knowledge, bind parameters doesn't apply to elements of the query like sort.

        That one you'll have to build the string with it.

        G Offline
        G Offline
        gaab
        wrote on 10 Mar 2019, 19:13 last edited by
        #3

        @SGaist

        My bad ! I did not think to check the docs on that point !

        A big thanks
        Gérard

        1 Reply Last reply
        0

        3/3

        10 Mar 2019, 19:13

        • Login

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