SELECT
*
FROM workers
WHERE id>=2 AND id<=6
ORDER BY age
UPDATE tbl SET
number=(@cnt:=@cnt+1)
WHERE !@cnt:=0
ORDER BY id DESC
WITH recursive hours (n) AS (
SELECT (@q:=0) n FROM dual
UNION ALL
SELECT (@q:=@q+1) n FROM hours WHERE @q<24
)
SELECT hours.n, ваш_запрос.* FROM ваш_запрос
RIGHT JOIN hours ON ваш_запрос.час = hours.n
WITH recursive hours (n) AS (
SELECT CONCAT("0",CAST(@q:=0 as varchar(1))) n FROM dual
UNION ALL
SELECT LPAD(CAST(@q:=@q+1 as varchar(2)),2,"0") n FROM hours WHERE @q<24
)
SELECT hours.n, ваш_запрос.* FROM ваш_запрос
RIGHT JOIN hours ON ваш_запрос.час = hours.n
ALTER TABLE table AUTO_INCREMENT = 100
WITH discussion_count AS (
SELECT count(*) cnt FROM discussion WHERE author_id=?
),
discussion_messages_count AS (
SELECT count(*) cnt FROM discussion_messages WHERE author_id=?
)
SELECT
p.name, dc.cnt discussions, dmc.cnt dcount
FROM people p, discussion_count dc, discussion_messages_count dmc
WHERE p.id=?
count=100; i=0; find . -maxdepth 1 -type f | while read f; do n=$[i/c+1]; i=$[i+1]; mkdir -p "$n" && mv "$f" "$n/$f"; done