>I want to SELECT on one term & have the SELECT return as quickly as >possible on the first TRUE instance. > >Ideally I'd like it to after the first matching case stop looking >for other matches ( for speed ) and return 1. If there's no matches >at all I want it to return 0. > >This works OK but returns either the date or an empty set. > >SELECT thread_last_post_date FROM threads WHERE >thread_last_post_date > '2001-02-01' LIMIT 1; > >I know from Perl or PHP I can check the number of returned rows but >I'd like something that just returns 0 or 1 so I don't have to >special case. > >I'd like something like below but which work (it returns 2 rows of 1 >for some reason ) : > >SELECT 1 FROM threads WHERE thread_last_post_date > '2001-02-01' LIMIT 1; > >thanks, > >- Sam. Sir, SQL deals with sets of rows. You supply the specifications, and SQL returns the set of all rows that match your specifications. SQL is deliberately designed not to deal with a database one row at a time. Try SELECT Count(*) FROM threads WHERE thread_last_post_date > '2001-02-01' Treat zero as zero and anything greater than zero as one. Bob Hall Know thyself? Absurd direction! Bubbles bear no introspection. -Khushhal Khan Khatak --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php