Hello, It seems to me that there is a fundamental reason why this can not be accomplished with a single SQL query. The process requires that the search algorithm maintains state between rows. i.e. the decision to keep or discard rows from the table as the algorithm descends down the table is not made based on the content of the current row. rather it is made based on whether the search process has encountered the start row (with the desired field1) and has not yet encountered the end row (with the matching field2). As far as I know it is not possible for a single SQL query to maintain state between rows. hence this has to be accomplished by multiple SQL queries. one to establish the start and end row indices. and then another that would take the row indices as constants and extracts the desired portion of the table. so in fact this might be appropriately labeled as an 'impossible' SQL query!
in any event, I am still new to SQL. please correct me if I'm wrong. Murad Nayal Charlie wrote: > > Thanks for the reply, but it isn't quite what is needed. > > The problem is that I need all the records between the two occurances of > identical values in field 2, with no records which occur before or after > those two occurances. > > For example, the following table with 3 fields: > 1 1 10 > 2 4 99 > 3 2 99 > 4 1 98 > 5 4 88 > 6 2 97 > > If the parameter for the second column is 4, I would need to retrieve > records 2, 3, and 4. > If the query needs, for simplicity, to return record 5, that could be > handled by the program. > > Thanks for your thoughts!! > Charlie > > --------------------------------------------------------------------- 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