Results 1 to 6 of 6

Thread: QSqlQuery bindValue and SELECT WHERE IN

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2010
    Location
    Opole, PL
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    1

    Default Re: QSqlQuery bindValue and SELECT WHERE IN

    Of course, I'm aware of that, it's not a clean solution. Someone could play with parsing SQL query and replacing single unnamed parameter with QList::count() parameters, then binding them all. Question is: is it worth? Because for me, it's dirty for sure.

    Since I don't have much experience with Qt/C++ and SQL programming, so far I never needed to use queries with variable abount of parameters. Maybe some ORM framework would fit here, but I don't know how ORM offer looks in C++ world.
    In the 1960's people took LSD to make the world weird.
    Now the world is weird and people take Prozac to make it normal.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QSqlQuery bindValue and SELECT WHERE IN

    A solution to this concrete problem would probably be to use a subquery returning the list. Something like:
    SQL Code:
    1. SELECT * FROM stuff WHERE id IN (SELECT stuff_id FROM foreigntable WHERE value < :value)
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. QSqlQuery and single quotes using bindValue
    By Luc4 in forum Qt Programming
    Replies: 4
    Last Post: 26th September 2010, 23:34
  2. QSqlQuery::bindValue
    By viglu in forum Newbie
    Replies: 3
    Last Post: 29th March 2010, 20:13
  3. QSqlQuery::bindValue() Question
    By kandalf in forum Qt Programming
    Replies: 7
    Last Post: 30th January 2010, 12:14
  4. QSqlQuery, bindValue and Sqlite
    By cydside in forum Qt Programming
    Replies: 4
    Last Post: 5th April 2009, 16:53
  5. QSqlQuery::bindValue problem
    By segfault in forum Qt Programming
    Replies: 6
    Last Post: 11th March 2009, 07:27

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.