Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email email@example.com
From: Waynn Lue (waynnluegmail.com)
Date: Sat Nov 15 2008 - 21:51:32 CST
Yeah, so a UNION would work, would this solution be faster than using
a subquery (my instinct says yes) but thought I would ask. They both
execute fast on my system so it's hard to say under load.
On 11/12/08, Dan Nelson <dnelsonallantgroup.com> wrote:
> In the last episode (Nov 12), Waynn Lue said:
>> I'm trying to find the first row before and the first row after a specific
>> row. Essentially I want to do these two queries, and get each row.
>> SELECT * FROM Users WHERE UserId = <userId> ORDER BY UserId DESC LIMIT 1;
>> SELECT * FROM Users WHERE UserId = <userId> ORDER BY UserId LIMIT 1;
>> Is there any way to combine this into one query? OFFSET doesn't allow a
>> negative number, which is essentially what I want.
> How about joining them with a UNION? Two queries for the round-trip
> cost of one!
> Dan Nelson
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: http://lists.mysql.com/mysql?unsub=waynnluegmail.com
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql