Results 1 to 20 of 21

Thread: Complex query in QSqlQuery

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2006
    Posts
    126
    Thanks
    17
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Complex query in QSqlQuery

    Hi,

    I have this query for MySQL:
    sql Code:
    1. SELECT @m:=(
    2. SELECT COUNT(cardid)
    3. FROM `transactions`
    4. WHERE
    5. operation>=1000 AND
    6. operation<2000 AND
    7. date<:beginDate
    8. );
    9.  
    10. SELECT
    11. @m:=@m+1 AS 'id',
    12. t.date,
    13. o.name,
    14. t.amount
    15. FROM `transactions` AS t
    16. INNER JOIN `operations` AS o ON t.operation=o.id
    17. WHERE
    18. operation>=1000 && operation<2000 AND
    19. date>=:beginDate AND
    20. date<=:endDate
    21. ORDER BY date;
    To copy to clipboard, switch view to plain text mode 

    And I try to execute it with QSqlQuery and it returns error. I prepare and bind the values for :beginDate and :endDate before executing it.

    Can't be used querys with vars from QSqlQuery?
    Last edited by wysota; 14th March 2008 at 11:16.

Similar Threads

  1. Problems with QSqlQuery update
    By whoops.slo in forum Qt Programming
    Replies: 4
    Last Post: 28th August 2006, 07:17

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.