Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
https://ru.stackoverflow.com/questions/663810
#MySQL 5.7.12 #please drop objects you've created at the end of the script #or check for their existance before creating #'\\' is a delimiter create table if not exists news (id int primary key, tm datetime, tex varchar(50)); INSERT INTO news (id, tm, tex) VALUES (1, '20160106', 'sdfasdfasd'), (2,'20160106', 'adfgvxzcv'), (3,'20160108', 'asdgfarv'), (4,'20160107', 'adfgader'), (5,'20160108', 'hstwadb'), (6,'20160109', 'asdfbvzx'), (7,'20160102', 'xcdbhsfghs'), (8,'20160101', 'afscvrbgvt'), (9,'20160103', 'bsgfa'), (10,'20160104', 'xcgd'), (11,'20160110', 'frtret'), (12,'20160111', 'asdvcx'), (13,'20160108', 'fgasdfg'), (14,'20160112', 'adsgadfg'), (15,'20160103', 'asdfgadfg'), (16,'20160114', 'fkadsmfa'), (17,'20160101', 'sdfg'), (18,'20160102', 'ahsfgh'), (19,'20160107', 'gbnxcvnbxcv'), (20,'20160107', 'xcvbnxcvbxcvb'); SELECT 'первый набор'; SELECT * FROM news AS nl ORDER BY nl.tm ASC, nl.id DESC LIMIT 10; SELECT 'второй набор. передаем в него id = 20 и tm = 07.01.2016 00:00:00'; SELECT * FROM news AS nl WHERE -- вставляем зачения последней строки из первого select (nl.tm > '20160107') OR ( nl.tm = '20160107' AND nl.Id < '20' ) ORDER BY nl.tm ASC, nl.id DESC LIMIT 10; DROP table news;
run
|
edit
|
history
|
help
0
flujo1
Select state by json
Кутарева Елена
Amp
ITM_14210069
Reviews and Permissions
test
Subrahmanyamk
mysql - where (between)
My tables