Results 1 to 20 of 20

Thread: select query with like

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: select query with like

    It should be:
    Qt Code:
    1. QSqlQuery query2("SELECT title * from mediadetails where title LIKE '%' || :title || '%' ");
    To copy to clipboard, switch view to plain text mode 
    or
    Qt Code:
    1. query2.bindValue(":title" "%" + LEdit1 + "%");
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2008
    Location
    India
    Posts
    31
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: select query with like

    its not working ........
    plzzzzzzzzzzz check again for any problem..if there??
    @shish

  3. #3
    Join Date
    Mar 2008
    Posts
    7
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: select query with like

    thanks for reply

    check this again

    this not working properly

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: select query with like

    Quote Originally Posted by ag.sitesh View Post
    this not working properly
    Indeed, there's another mistake. It should be:
    Qt Code:
    1. QSqlQuery query2;
    2. query2.prepare(...);
    3. query2.bindValue( ... );
    4. ...
    To copy to clipboard, switch view to plain text mode 
    QSqlQuery::QSqlQuery( const QString & ) constructor executes the query, so you can't use it with placeholders.

  5. #5
    Join Date
    Oct 2007
    Location
    Cracow
    Posts
    56
    Thanks
    1
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: select query with like

    I think that problem is in SELECT
    Quote Originally Posted by jacek View Post
    Qt Code:
    1. QSqlQuery query2("SELECT title * from mediadetails where title LIKE '%' || :title || '%' ");
    To copy to clipboard, switch view to plain text mode 
    it should be comma before '*'

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: select query with like

    Quote Originally Posted by mazurekwrc View Post
    it should be comma before '*'
    Yes, that's the third problem.

  7. #7
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: select query with like

    Qt Code:
    1. query2.bindValue(":title" "%" + LEdit1 + "%");
    To copy to clipboard, switch view to plain text mode 
    ... and there a comma is missing ;-)
    Qt Code:
    1. query2.bindValue(":title", "%" + LEdit1 + "%");
    To copy to clipboard, switch view to plain text mode 

    And by the way, I guess that the || is only understood by oracle. If using MySql use the CONCAT function.

    Lykurg

  8. #8
    Join Date
    Jan 2008
    Location
    India
    Posts
    31
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Thumbs down Re: select query with like

    its not working guys........
    its shows error unable to fetch data...........
    can u write and test any small code on any of ur table in mysql and then post it here plzzz.....
    becoz its a basic search only ...!!!
    which must be done...
    @shish

Similar Threads

  1. Unable to fetch data when searching through select query
    By sinha.ashish in forum Qt Programming
    Replies: 3
    Last Post: 10th April 2008, 14:06
  2. Select query using mysql for searching
    By sinha.ashish in forum Qt Programming
    Replies: 4
    Last Post: 10th April 2008, 06:14
  3. Sql Server cannot retrieve data from select
    By Atomino in forum Qt Programming
    Replies: 10
    Last Post: 7th September 2006, 16:37
  4. Aborting a query set on a TableModel
    By Quid in forum Qt Programming
    Replies: 2
    Last Post: 5th July 2006, 22:36
  5. Record update windowd entered data saving
    By MarkoSan in forum Qt Programming
    Replies: 56
    Last Post: 18th January 2006, 18:50

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.