I have a table with a name scoreswith columns idand score. I want to access a specific record on it id, as well as 5 records before and after it. Is there a way in SQL to say "grab a bill with id nand xelements before and after it?"
scores
id
score
n
x
Try:
SELECT * FROM scores WHERE score >= n ORDER BY score ASC LIMIT 6 UNION SELECT * FROM scores WHERE score < n ORDER BY score DESC LIMIT 5
The syntax may vary slightly depending on which database server you are using.
Source: https://habr.com/ru/post/1737261/More articles:Why is fishing the most useful shuffling algorithm? - algorithmDo I need to automatically log in after activating an account? - user-interfaceCreating a single WSDL file for several classes - javaGetting EXC_BAD_ACCESS without any useful messages from NSZombieEnabled - stack-traceUser Interface Code Level Templates? - user-interfaceCan a tornado communicate with Cassandra in a non-blocking asynchronous style? - asynchronousOSX: how to get volume name (or bsd name) from IOUSBDeviceInterface identifier or location - usbРедактировать CSS с помощью Delphi - htmlGet computer name in C # without link to Microsoft.VisualBasic.dll - c #JQueryValidation - input error class name - jqueryAll Articles