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
gustavoclientes
ayushagg31.c
MySQL Practice
calculate averages for students and levels
How to run query to keep maximum 3 rows with the same name
exp11
ITM_14210069
mysql - update
proj
SELECT YEAR('2019-08-15 01:02:03')+10