SELECT data_json -> "$.books[*].id" FROM test
To use a literal instance of a special character in a regular expression, precede it by two backslash (\) characters. The MySQL parser interprets one of the backslashes, and the regular expression library interprets the other. For example, to match the string 1+2 that contains the special + character, only the last of the following regular expressions is the correct one:mysql> SELECT REGEXP_LIKE('1+2', '1+2'); -> 0 mysql> SELECT REGEXP_LIKE('1+2', '1\+2'); -> 0 mysql> SELECT REGEXP_LIKE('1+2', '1\\+2'); -> 1
CREATE TABLE tmp (
id INT,
color VARCHAR(255)
);
INSERT INTO tmp
(id, color)
VALUES
(1, 'зеленый'),
(2, 'красный'),
(3, 'синий'),
(4, 'белый')
;
SELECT id, color FROM (
SELECT
id,
@join_pk_1:=@join_pk_1 + 1 as join_pk
FROM tmp, (select @join_pk_1:=0) as join_pk_1
ORDER BY id DESC
) as tbl1
LEFT JOIN (
SELECT
color,
@join_pk_2:=@join_pk_2 + 1 as join_pk
FROM tmp, (select @join_pk_2:=0) as join_pk_2
) as tbl2
ON tbl1.join_pk = tbl2.join_pk
id color
4 зеленый
3 красный
2 синий
1 белый
Когда производится конкатенация строк с помощью оператора ".", разрешается разрывать..
$sql = "SELECT `id`, `name` FROM `people` "
. "WHERE `name` = 'Susan' "
// закомментировано на время отладки
// . "ORDER BY `name` ASC "
. "ORDER BY `name` DESC LIMIT 5"
;