Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Database SELECT using two conditions???

I am trying to query a database and retrieve a row matching two conditions

Titanium Code: I have tried both of the following

var resultSet = db.execute('SELECT * FROM goals WHERE goal_type= "current" AND client_id = ?', id);

var resultSet = db.execute('SELECT * FROM goals WHERE goal_type= ? AND client_id = ?', 'current', id);

I get an error in the console: NOT FOUND

When I query the database in cmd prompt it returns 1 row:

SELECT * FROM goals WHERE goal_type = 'current' AND client_id = 7002;

Does anyone know where im going wrong here?

Trent

— asked December 1st 2010 by Trenton Bishop
  • database
  • desktop
1 Comment
  • Trenton

    Would you please pastebin the full error output? Thanks

    — commented December 1st 2010 by Paul Dowsett

1 Answer

  • Are you sure you have more than one row that meets that condition? Each row that you want returned would have to have the goal_type='current' AND the client_id=7002 . Not OR.

    — answered December 1st 2010 by Josh Lewis
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.