Re: [sqlite] Re[sqlite] trieving only one record in the database
This is the syntax of a select statement as shown in the manual: SELECT [ALL | DISTINCT] result [FROM table-list] [WHERE expr] [GROUP BY expr-list] [HAVING expr] [compound-op select]* [ORDER BY sort-expr-list] [LIMIT integer [( OFFSET | , ) integer]] The bit you want is LIMIT[integer]. Say LIMIT 1 and you'll get one record of the found set. Mike On 25/01/2008 13:45:32, arbalest06 ([EMAIL PROTECTED]) wrote: Good day! I want to retrieve only one record in the database with a condition that may cause a retrieval of many records. The purpose of this is for me to check only if there is at least 1 record in the database. So if given my condition, the query would now search for one record in the database that satisfies the condition the returns that record. After one record is found, it should now stop finding and retrieving other records that satisfies the condition. How can i do this? What query can i issue? Thank you and God bless! -- View this message in context: http://www.nabble.com/Retrieving-only-one- record-in-the-database-tp15087994p15087994.html Sent from the SQLite mailing list archive at Nabble.com. - To unsubscribe, send email to [EMAIL PROTECTED] - - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Re[sqlite] trieving only one record in the database
You could do SELECT whatever FROM table WHERE criteria LIMIT 1 or SELECT COUNT(*) AS RowCount FROM table WHERE criteria Then just check that the value of RowCount > 0. The nice thing about the latter is that now you are set up if you ever want to know how many rows meet the criteria that you've chosen. -- Eric Pankoke Founder / Lead Developer Point Of Light Software http://www.polsoftware.com/ -- Original message -- From: arbalest06 <[EMAIL PROTECTED]> > > Good day! > > I want to retrieve only one record in the database with a condition that may > cause a retrieval of many records. The purpose of this is for me to check > only if there is at least 1 record in the database. So if given my > condition, the query would now search for one record in the database that > satisfies the condition the returns that record. After one record is found, > it should now stop finding and retrieving other records that satisfies the > condition. How can i do this? What query can i issue? > > Thank you and God bless! > -- > View this message in context: > http://www.nabble.com/Retrieving-only-one-record-in-the-database-tp15087994p1508 > 7994.html > Sent from the SQLite mailing list archive at Nabble.com. > > > - > To unsubscribe, send email to [EMAIL PROTECTED] > - > - To unsubscribe, send email to [EMAIL PROTECTED] -
[sqlite] Re[sqlite] trieving only one record in the database
Good day! I want to retrieve only one record in the database with a condition that may cause a retrieval of many records. The purpose of this is for me to check only if there is at least 1 record in the database. So if given my condition, the query would now search for one record in the database that satisfies the condition the returns that record. After one record is found, it should now stop finding and retrieving other records that satisfies the condition. How can i do this? What query can i issue? Thank you and God bless! -- View this message in context: http://www.nabble.com/Retrieving-only-one-record-in-the-database-tp15087994p15087994.html Sent from the SQLite mailing list archive at Nabble.com. - To unsubscribe, send email to [EMAIL PROTECTED] -