Prior to MySQL 8.0.4, MySQL used the Henry Spencer regular expression library to support regular expression operations, rather than International Components for Unicode (ICU).
...
The Spencer library supports word-beginning and word-end boundary markers ([[:<:]] and [[:>:]] notation). ICU does not. For ICU, you can use \b to match word boundaries; double the backslash because MySQL interprets it as the escape character within strings.
\\b111,222,333\\b
WITH
`counts` AS (
SELECT `film_id`, `nomin_id`, COUNT(*) AS `votes_count`,
FROM `votes`
GROUP BY `nomin_id`, `film_id`
).
`places` AS (
SELECT `film_id`, `nomin_id`, `votes_count`,
ROW_NUMBER() OVER `win` AS `place`
FROM `counts`
WINDOW `win` AS (
PARTITION BY `nomin_id`
ORDER BY `votes_count` DESC
)
)
SELECT `votes_count`, `nomin_id`, `film_id`, `place`
FROM `places`
WHERE `place` <= 5
- $result = $connect->query($sql);
- $rows = $result->fetch();
- if($rows != 0)
- {
- for ($i = 0;$i < $rows;$i ++)
- {
- $result->data_seek($i);
- $map = $result->fetch_assoc();
+ foreach ($connect->query($sql) as $map) {
- }
- $result->close();
- if($x > 0) $left = (3000 + abs($x))/5.3;
- else $left = (3000 - abs($x))/5.3;
+ $left = (3000 + $x)/5.3;
- if($y > 0) $top = (3000 - abs($y))/5.3;
- else $top = (3000 + abs($y))/5.3;
+ $top = (3000 - $y)/5.3;
`groups`
. Должен вернуть одну строку с id 10 (последняя строка в выборке на скриншоте)Кому должен? Программа должна делать только то, что вы в ней написали. Строки по колонке mentions отсортированы, десятая строка выбрана. То, что нет других правил сортировки означает, что строки с одинаковым значением mentions можно выдавать в любом порядке.
WITH
`cte1` AS (
SELECT `to_user_id` AS `respondent`, `message`, `datetime`,
'outgoing' AS `direction`
FROM `messages`
WHERE `from_user_id` = :userId
UNION ALL
SELECT `from_user_id`, `message`, `datetime`,
'incoming' AS `direction`
FROM `messages`
WHERE `to_user_id` = :userId
),
`cte2` AS (
SELECT `respondent`, `message`, `datetime`, `direction`,
ROW_NUMBER() OVER `w` AS `row_num`
FROM `cte1`
WINDOW `w` AS (
PARTITION BY `respondent`
ORDER BY `datetime` DESC
)
)
SELECT `respondent`, `message`, `datetime`, `direction`
FROM `cte2`
WHERE `row_num` = 1