INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (179, 31, 'DATE\\_FORMAT', 'Syntax\n------\n\nDATE_FORMAT(date, format[, locale])\n\nDescription\n-----------\n\nFormats the date value according to the format string.\n\nThe language used for the names is controlled by the value of the lc_time_names system variable. See server locale for more on the supported locales.\n\nDate Formatting Options\n\nThe options that can be used by DATE_FORMAT(), as well as its inverse STR_TO_DATE() and the FROM_UNIXTIME() function, are:\n\n| Option | Description                                                                                                                                                                                      |\n| ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| %a     | Short weekday name in current locale (Variable lc_time_names).                |\n| %b     | Short form month name in current locale. For locale en_US this is one of: Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, or Dec.                                                       |\n| %c     | Month with 1 or 2 digits.                                                                                                                                                                        |\n| %D     | Day with English suffix ''th'', ''nd'', ''st'' or ''rd''''. (1st, 2nd, 3rd...).                                                                                                                           |\n| %d     | Day with 2 digits.                                                                                                                                                                               |\n| %e     | Day with 1 or 2 digits.                                                                                                                                                                          |\n| %f     | Microseconds 6 digits.                                                                                                                                             |\n| %H     | Hour with 2 digits between 00-23.                                                                                                                                                                |\n| %h     | Hour with 2 digits between 01-12.                                                                                                                                                                |\n| %I     | Hour with 2 digits between 01-12.                                                                                                                                                                |\n| %i     | Minute with 2 digits.                                                                                                                                                                            |\n| %j     | Day of the year (001-366)                                                                                                                                                                        |\n| %k     | Hour with 1 digits between 0-23.                                                                                                                                                                 |\n| %l     | Hour with 1 digits between 1-12.                                                                                                                                                                 |\n| %M     | Full month name in current locale (Variable lc_time_names).                   |\n| %m     | Month with 2 digits.                                                                                                                                                                             |\n| %p     | AM/PM according to current locale (Variable lc_time_names).                   |\n| %r     | Time in 12 hour format, followed by AM/PM. Short for ''%I:%i:%S %p''.                                                                                                                              |\n| %S     | Seconds with 2 digits.                                                                                                                                                                           |\n| %s     | Seconds with 2 digits.                                                                                                                                                                           |\n| %T     | Time in 24 hour format. Short for ''%H:%i:%S''.                                                                                                                                                    |\n| %U     | Week number (00-53), when first day of the week is Sunday.                                                                                                                                       |\n| %u     | Week number (00-53), when first day of the week is Monday.                                                                                                                                       |\n| %V     | Week number (01-53), when first day of the week is Sunday. Used with %X.                                                                                                                         |\n| %v     | Week number (01-53), when first day of the week is Monday. Used with %x.                                                                                                                         |\n| %W     | Full weekday name in current locale (Variable lc_time_names).                 |\n| %w     | Day of the week. 0 = Sunday, 6 = Saturday.                                                                                                                                                       |\n| %X     | Year with 4 digits when first day of the week is Sunday. Used with %V.                                                                                                                           |\n| %x     | Year with 4 digits when first day of the week is Monday. Used with %v.                                                                                                                           |\n| %Y     | Year with 4 digits.                                                                                                                                                                              |\n| %y     | Year with 2 digits.                                                                                                                                                                              |\n| %Z     | Timezone abbreviation. From MariaDB 11.3.0.                                                          |\n| %z     | Numeric timezone +hhmm or -hhmm presenting the hour and minute offset from UTC. From MariaDB 11.3.0. |\n| %#     | For str_to_date(), skip all numbers.                                                                                                                                         |\n| %.     | For str_to_date(), skip all punctation characters.                                                                                                                           |\n| %@     | For str_to_date(), skip all alpha characters.                                                                                                                                |\n| %%     | A literal % character.                                                                                                                                                                           |\n\nTo get a date in one of the standard formats, GET_FORMAT() can be used.\n\nExamples\n--------\n\nSELECT DATE_FORMAT(''2009-10-04 22:23:00'', ''%W %M %Y'');\n+------------------------------------------------+\n| DATE_FORMAT(''2009-10-04 22:23:00'', ''%W %M %Y'') |\n+------------------------------------------------+\n| Sunday October 2009                            |\n+------------------------------------------------+\n\nSELECT DATE_FORMAT(''2007-10-04 22:23:00'', ''%H:%i:%s'');\n+------------------------------------------------+\n| DATE_FORMAT(''2007-10-04 22:23:00'', ''%H:%i:%s'') |\n+------------------------------------------------+\n| 22:23:00                                       |\n+------------------------------------------------+\n\nSELECT DATE_FORMAT(''1900-10-04 22:23:00'', ''%D %y %a %d %m %b %j'');\n+------------------------------------------------------------+\n| DATE_FORMAT(''1900-10-04 22:23:00'', ''%D %y %a %d %m %b %j'') |\n+------------------------------------------------------------+\n| 4th 00 Thu 04 10 Oct 277                                   |\n+------------------------------------------------------------+\n\nSELECT DATE_FORMAT(''1997-10-04 22:23:00'', ''%H %k %I %r %T %S %w'');\n+------------------------------------------------------------+\n| DATE_FORMAT(''1997-10-04 22:23:00'', ''%H %k %I %r %T %S %w'') |\n+------------------------------------------------------------+\n| 22 22 10 10:23:00 PM 22:23:00 00 6                         |\n+------------------------------------------------------------+\n\nSELECT DATE_FORMAT(''1999-01-01'', ''%X %V'');\n+------------------------------------+\n| DATE_FORMAT(''1999-01-01'', ''%X %V'') |\n+------------------------------------+\n| 1998 52                            |\n+------------------------------------+\n\nSELECT DATE_FORMAT(''2006-06-00'', ''%d'');\n+---------------------------------+\n| DATE_FORMAT(''2006-06-00'', ''%d'') |\n+---------------------------------+\n| 00                              |\n+---------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/date_format', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/date_format');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (180, 31, 'DATE\\_SUB', 'Syntax\n------\n\nDATE_SUB(date,INTERVAL expr unit)\n\nDescription\n-----------\n\nPerforms date arithmetic. The _date_ argument specifies the starting date or datetime value. _expr_ is an expression specifying the interval value to be subtracted from the starting date. _expr_ is a string; it may start with a "-" for negative intervals. _unit_ is a keyword indicating the units in which the expression should be interpreted. See Date and Time Units for a complete list of permitted units.\n\nSee also DATE_ADD().\n\nExamples\n--------\n\nSELECT DATE_SUB(''1998-01-02'', INTERVAL 31 DAY);\n+-----------------------------------------+\n| DATE_SUB(''1998-01-02'', INTERVAL 31 DAY) |\n+-----------------------------------------+\n| 1997-12-02                              |\n+-----------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/date_sub', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/date_sub');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (181, 31, 'DATEDIFF', 'Syntax\n------\n\nDATEDIFF(expr1,expr2)\n\nDescription\n-----------\n\nDATEDIFF() returns (_expr1_ – _expr2_) expressed as a value in days from one date to the other. _expr1_ and _expr2_ are date or date-and-time expressions. Only the date parts of the values are used in the calculation.\n\nExamples\n--------\n\nSELECT DATEDIFF(''2007-12-31 23:59:59'',''2007-12-30'');\n+----------------------------------------------+\n| DATEDIFF(''2007-12-31 23:59:59'',''2007-12-30'') |\n+----------------------------------------------+\n|                                            1 |\n+----------------------------------------------+\n\nSELECT DATEDIFF(''2010-11-30 23:59:59'',''2010-12-31'');\n+----------------------------------------------+\n| DATEDIFF(''2010-11-30 23:59:59'',''2010-12-31'') |\n+----------------------------------------------+\n|                                          -31 |\n+----------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/datediff', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/datediff');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (182, 31, 'DAY', 'Syntax\n------\n\nDAY(date)\n\nDescription\n-----------\n\nDAY() is a synonym for DAYOFMONTH().\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/day', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/day');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (183, 31, 'DAYNAME', 'Syntax\n------\n\nDAYNAME(date)\n\nDescription\n-----------\n\nReturns the name of the weekday for date. The language used for the name is controlled by the value\\\nof the lc_time_names system variable. See server locale for more on the supported locales.\n\nExamples\n--------\n\nSELECT DAYNAME(''2007-02-03'');\n+-----------------------+\n| DAYNAME(''2007-02-03'') |\n+-----------------------+\n| Saturday              |\n+-----------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/dayname', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/dayname');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (184, 31, 'DAYOFMONTH', 'Syntax\n------\n\nDAYOFMONTH(date)\n\nDescription\n-----------\n\nReturns the day of the month for date, in the range 1 to 31, or 0 for dates such as ''0000-00-00'' or ''2008-00-00'' which have a zero day part.\n\nDAY() is a synonym.\n\nExamples\n--------\n\nSELECT DAYOFMONTH(''2007-02-03'');\n+--------------------------+\n| DAYOFMONTH(''2007-02-03'') |\n+--------------------------+\n|                        3 |\n+--------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/dayofmonth', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/dayofmonth');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (185, 31, 'DAYOFWEEK', 'Syntax\n------\n\nDAYOFWEEK(date)\n\nDescription\n-----------\n\nReturns the day of the week index for the date (1 = Sunday, 2 = Monday, ..., 7 = Saturday). These index values correspond to the ODBC standard.\n\nThis contrasts with WEEKDAY() which follows a different index numbering (0 = Monday, 1 = Tuesday, ... 6 = Sunday).\n\nExamples\n--------\n\nSELECT DAYOFWEEK(''2007-02-03'');\n+-------------------------+\n| DAYOFWEEK(''2007-02-03'') |\n+-------------------------+\n|                       7 |\n+-------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/dayofweek', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/dayofweek');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (186, 31, 'DAYOFYEAR', 'Syntax\n------\n\nDAYOFYEAR(date)\n\nDescription\n-----------\n\nReturns the day of the year for date, in the range 1 to 366.\n\nExamples\n--------\n\nSELECT DAYOFYEAR(''2018-02-16'');\n+-------------------------+\n| DAYOFYEAR(''2018-02-16'') |\n+-------------------------+\n|                      47 |\n+-------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/dayofyear', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/dayofyear');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (187, 31, 'EXTRACT', 'Syntax\n------\n\nEXTRACT(unit FROM date)\n\nDescription\n-----------\n\nThe EXTRACT() function extracts the required unit from the date. See Date and Time Units for a complete list of permitted units.\n\nHOUR() is not a standard SQL function, so continues to adhere to the old behavior inherited from MySQL.\n\nExamples\n--------\n\nSELECT EXTRACT(YEAR FROM ''2009-07-02'');\n+---------------------------------+\n| EXTRACT(YEAR FROM ''2009-07-02'') |\n+---------------------------------+\n|                            2009 |\n+---------------------------------+\n\nSELECT EXTRACT(YEAR_MONTH FROM ''2009-07-02 01:02:03'');\n+------------------------------------------------+\n| EXTRACT(YEAR_MONTH FROM ''2009-07-02 01:02:03'') |\n+------------------------------------------------+\n|                                         200907 |\n+------------------------------------------------+\n\nSELECT EXTRACT(DAY_MINUTE FROM ''2009-07-02 01:02:03'');\n+------------------------------------------------+\n| EXTRACT(DAY_MINUTE FROM ''2009-07-02 01:02:03'') |\n+------------------------------------------------+\n|                                          20102 |\n+------------------------------------------------+\n\nSELECT EXTRACT(MICROSECOND FROM ''2003-01-02 10:30:00.000123'');\n+--------------------------------------------------------+\n| EXTRACT(MICROSECOND FROM ''2003-01-02 10:30:00.000123'') |\n+--------------------------------------------------------+\n|                                                    123 |\n+--------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/extract', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/extract');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (188, 31, 'FORMAT\\_PICO\\_TIME', 'Syntax\n------\n\nFORMAT_PICO_TIME(time_val)\n\nDescription\n-----------\n\nGiven a time in picoseconds, returns a human-readable time value and unit indicator. Resulting unit is dependent on the length of the argument, and can be:\n\n ps - picoseconds\n ns - nanoseconds\n us - microseconds\n ms - milliseconds\n s - seconds\n min - minutes\n h - hours\n d - days\n\nWith the exception of results under one nanosecond, which are not rounded and are represented as whole numbers, the result is rounded to 2 decimal places, with a minimum of 3 significant digits.\n\nReturns NULL if the argument is NULL.\n\nThis function is very similar to the Sys Schema FORMAT_TIME function, but with the following differences:\n\n Represents minutes as min rather than m.\n Does not represent weeks.\n\nExamples\n--------\n\nSELECT\n    FORMAT_PICO_TIME(43) AS ps,\n    FORMAT_PICO_TIME(4321) AS ns, \n    FORMAT_PICO_TIME(43211234) AS us,\n    FORMAT_PICO_TIME(432112344321) AS ms,\n    FORMAT_PICO_TIME(43211234432123) AS s,\n    FORMAT_PICO_TIME(432112344321234) AS m,\n    FORMAT_PICO_TIME(4321123443212345) AS h,\n    FORMAT_PICO_TIME(432112344321234545) AS d;\n+--------+---------+----------+-----------+---------+----------+--------+--------+\n| ps     | ns      | us       | ms        | s       | m        | h      | d      |\n+--------+---------+----------+-----------+---------+----------+--------+--------+\n|  43 ps | 4.32 ns | 43.21 us | 432.11 ms | 43.21 s | 7.20 min | 1.20 h | 5.00 d |\n+--------+---------+----------+-----------+---------+----------+--------+--------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/format_pico_time', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/format_pico_time');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (189, 31, 'FROM\\_DAYS', 'Syntax\n------\n\nFROM_DAYS(N)\n\nDescription\n-----------\n\nGiven a day number N, returns a DATE value. The day count is based on the number of days from the start of the standard calendar (0000-00-00).\n\nThe function is not designed for use with dates before the advent of the Gregorian calendar in October 1582. Results will not be reliable since it doesn''t account for the lost days when the calendar changed from the Julian calendar.\n\nThis is the converse of the TO_DAYS() function.\n\nExamples\n--------\n\nSELECT FROM_DAYS(730669);\n+-------------------+\n| FROM_DAYS(730669) |\n+-------------------+\n| 2000-07-03        |\n+-------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/from_days', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/from_days');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (190, 31, 'FROM\\_UNIXTIME', 'Syntax\n------\n\nFROM_UNIXTIME(unix_timestamp)\nFROM_UNIXTIME(unix_timestamp,format)\n\nDescription\n-----------\n\nConverts the number of seconds from the epoch (1970-01-01 00:00:00 UTC) to aTIMESTAMP value, the opposite of what UNIX_TIMESTAMP() is doing. Returns NULL if the result would be outside of the valid range of TIMESTAMP values.\n\nIf format is given, the result is exactly equivalent to\n\n``sql\nDATE_FORMAT(FROM_UNIXTIME(unix_timestamp), format)\n`\n\nTimestamps in MariaDB have a maximum value of 4294967295, equivalent to 2106-02-07 06:28:15. This is due to the underlying 32-bit limitation. Using the function on a timestamp beyond this will result in NULL being returned. Use DATETIME as a storage type if you require dates beyond this.\n\nThe one-argument form of FROM_UNIXTIME() returns aDATETIME. This means that it can return values outside of valid TIMESTAMP range, in particular 1970-01-01 00:00:00. And it can return the same result for different values of unix_timestamp (around DST changes).\n\nTimestamps in MariaDB have a maximum value of 4294967295, equivalent to 2106-02-07 06:28:15. This is due to the underlying 32-bit limitation. Using the function on a timestamp beyond this will result in NULL being returned. Use DATETIME as a storage type if you require dates beyond this.\n\nThe one-argument form of FROM_UNIXTIME() returns aDATETIME. This means that it can return values outside of valid TIMESTAMP range, in particular 1970-01-01 00:00:00. And it can return the same result for different values of unix_timestamp (around DST changes).\n\nThe maximum value is 2147483647, equivalent to 2038-01-19 05:14:07.\n\nThe following options can be used by FROM_UNIXTIME(), as well as DATE_FORMAT() and STR_TO_DATE():\n\n| Option | Description                                                                                                                                                                       |\n| ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| %a     | Short weekday name in current locale (Variable lc_time_names). |\n| %b     | Short form month name in current locale. For locale en_US this is one of: Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov or Dec.                                                    |\n| %c     | Month with 1 or 2 digits.                                                                                                                                                         |\n| %D     | Day with English suffix ''th'', ''nd'', ''st'' or ''rd''''. (1st, 2nd, 3rd...).                                                                                                            |\n| %d     | Day with 2 digits.                                                                                                                                                                |\n| %e     | Day with 1 or 2 digits.                                                                                                                                                           |\n| %f     | Microseconds 6 digits.                                                                                                                              |\n| %H     | Hour with 2 digits between 00-23.                                                                                                                                                 |\n| %h     | Hour with 2 digits between 01-12.                                                                                                                                                 |\n| %I     | Hour with 2 digits between 01-12.                                                                                                                                                 |\n| %i     | Minute with 2 digits.                                                                                                                                                             |\n| %j     | Day of the year (001-366)                                                                                                                                                         |\n| %k     | Hour with 1 digits between 0-23.                                                                                                                                                  |\n| %l     | Hour with 1 digits between 1-12.                                                                                                                                                  |\n| %M     | Full month name in current locale (Variable lc_time_names).    |\n| %m     | Month with 2 digits.                                                                                                                                                              |\n| %p     | AM/PM according to current locale (Variable lc_time_names).    |\n| %r     | Time in 12 hour format, followed by AM/PM. Short for ''%I:%i:%S %p''.                                                                                                               |\n| %S     | Seconds with 2 digits.                                                                                                                                                            |\n| %s     | Seconds with 2 digits.                                                                                                                                                            |\n| %T     | Time in 24 hour format. Short for ''%H:%i:%S''.                                                                                                                                     |\n| %U     | Week number (00-53), when first day of the week is Sunday.                                                                                                                        |\n| %u     | Week number (00-53), when first day of the week is Monday.                                                                                                                        |\n| %V     | Week number (01-53), when first day of the week is Sunday. Used with %X.                                                                                                          |\n| %v     | Week number (01-53), when first day of the week is Monday. Used with %x.                                                                                                          |\n| %W     | Full weekday name in current locale (Variable lc_time_names).  |\n| %w     | Day of the week. 0 = Sunday, 6 = Saturday.                                                                                                                                        |\n| %X     | Year with 4 digits when first day of the week is Sunday. Used with %V.                                                                                                            |\n| %x     | Year with 4 digits when first day of the week is Sunday. Used with %v.                                                                                                            |\n| %Y     | Year with 4 digits.                                                                                                                                                               |\n| %y     | Year with 2 digits.                                                                                                                                                               |\n| %#     | For str_to_date(), skip all numbers.                                                                                                                          |\n| %.     | For str_to_date(), skip all punctation characters.                                                                                                            |\n| %@     | For str_to_date(), skip all alpha characters.                                                                                                                 |\n| %%     | A literal % character.                                                                                                                                                            |\n\nPerformance Considerations\n\nIf your session time zone is set to SYSTEM (the default), FROM_UNIXTIME() will call the OS function to convert the data using the system time zone. At least on Linux, the corresponding function (localtime_r`) uses a global mutex inside glibc that can cause contention under high concurrent load.\n\nSet your time zone to a named time zone to avoid this issue. See mysql time zone tables for details on how to do this.\n\nExamples\n--------\n\nSELECT FROM_UNIXTIME(1196440219);\n+---------------------------+\n| FROM_UNIXTIME(1196440219) |\n+---------------------------+\n| 2007-11-30 11:30:19       |\n+---------------------------+\n\nSELECT FROM_UNIXTIME(1196440219) + 0;\n+-------------------------------+\n| FROM_UNIXTIME(1196440219) + 0 |\n+-------------------------------+\n|         20071130113019.000000 |\n+-------------------------------+\n\nSELECT FROM_UNIXTIME(UNIX_TIMESTAMP(), ''%Y %D %M %h:%i:%s %x'');\n+---------------------------------------------------------+\n| FROM_UNIXTIME(UNIX_TIMESTAMP(), ''%Y %D %M %h:%i:%s %x'') |\n+---------------------------------------------------------+\n| 2010 27th March 01:03:47 2010                           |\n+---------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/from_unixtime', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/from_unixtime');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (191, 31, 'GET\\_FORMAT', 'Syntax\n------\n\nGET_FORMAT({DATE|DATETIME|TIME}, {''EUR''|''USA''|''JIS''|''ISO''|''INTERNAL''})\n\nDescription\n-----------\n\nReturns a format string. This function is useful in combination with the DATE_FORMAT() and the STR_TO_DATE() functions.\n\nPossible result formats are:\n\n| Function Call                    | Result Format       |\n| -------------------------------- | ------------------- |\n| GET_FORMAT(DATE,''EUR'')          | ''%d.%m.%Y''          |\n| GET_FORMAT(DATE,''USA'')          | ''%m.%d.%Y''          |\n| GET_FORMAT(DATE,''JIS'')          | ''%Y-%m-%d''          |\n| GET_FORMAT(DATE,''ISO'')          | ''%Y-%m-%d''          |\n| GET_FORMAT(DATE,''INTERNAL'')     | ''%Y%m%d''            |\n| GET_FORMAT(DATETIME,''EUR'')      | ''%Y-%m-%d %H.%i.%s'' |\n| GET_FORMAT(DATETIME,''USA'')      | ''%Y-%m-%d %H.%i.%s'' |\n| GET_FORMAT(DATETIME,''JIS'')      | ''%Y-%m-%d %H:%i:%s'' |\n| GET_FORMAT(DATETIME,''ISO'')      | ''%Y-%m-%d %H:%i:%s'' |\n| GET_FORMAT(DATETIME,''INTERNAL'') | ''%Y%m%d%H%i%s''      |\n| GET_FORMAT(TIME,''EUR'')          | ''%H.%i.%s''          |\n| GET_FORMAT(TIME,''USA'')          | ''%h:%i:%s %p''       |\n| GET_FORMAT(TIME,''JIS'')          | ''%H:%i:%s''          |\n| GET_FORMAT(TIME,''ISO'')          | ''%H:%i:%s''          |\n| GET_FORMAT(TIME,''INTERNAL'')     | ''%H%i%s''            |\n\nExamples\n--------\n\nSELECT GET_FORMAT(DATE, ''EUR'');\n+-------------------------+\n| GET_FORMAT(DATE, ''EUR'') |\n+-------------------------+\n| %d.%m.%Y                |\n+-------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/get_format', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/get_format');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (192, 31, 'HOUR', 'Description\n-----------\n\nReturns the hour for time. The range of the return value is 0 to 23 for time-of-day values. However, the range of TIME values actually is much larger, so HOUR can return values greater than 23.\n\nThe return value is always positive, even if a negative TIME value is provided.\n\nExamples\n--------\n\nSELECT HOUR(''10:05:03'');\n+------------------+\n| HOUR(''10:05:03'') |\n+------------------+\n|               10 |\n+------------------+\n\nSELECT HOUR(''272:59:59'');\n+-------------------+\n| HOUR(''272:59:59'') |\n+-------------------+\n|               272 |\n+-------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/hour', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/hour');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (193, 31, 'LAST\\_DAY', 'Syntax\n------\n\nLAST_DAY(date)\n\nDescription\n-----------\n\nTakes a date or datetime value and returns the corresponding value for the last day of the month. Returns NULL if the argument is invalid.\n\nExamples\n--------\n\nSELECT LAST_DAY(''2003-02-05'');\n+------------------------+\n| LAST_DAY(''2003-02-05'') |\n+------------------------+\n| 2003-02-28             |\n+------------------------+\n\nSELECT LAST_DAY(''2004-02-05'');\n+------------------------+\n| LAST_DAY(''2004-02-05'') |\n+------------------------+\n| 2004-02-29             |\n+------------------------+\n\nSELECT LAST_DAY(''2004-01-01 01:01:01'');\n+---------------------------------+\n| LAST_DAY(''2004-01-01 01:01:01'') |\n+---------------------------------+\n| 2004-01-31                      |\n+---------------------------------+\n\nSELECT LAST_DAY(''2003-03-32'');\n+------------------------+\n| LAST_DAY(''2003-03-32'') |\n+------------------------+\n| NULL                   |\n+------------------------+\n1 row in set, 1 warning (0.00 sec)\n\nWarning (Code 1292): Incorrect datetime value: ''2003-03-32''\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/last_day', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/last_day');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (194, 31, 'LOCALTIME', 'Syntax\n------\n\nLOCALTIME\nLOCALTIME([precision])\n\nDescription\n-----------\n\nLOCALTIME and LOCALTIME() are synonyms for NOW().\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/localtime', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/localtime');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (195, 31, 'LOCALTIMESTAMP', 'Syntax\n------\n\nLOCALTIMESTAMP\nLOCALTIMESTAMP([precision])\n\nDescription\n-----------\n\nLOCALTIMESTAMP and LOCALTIMESTAMP() are synonyms for NOW().\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/localtimestamp', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/localtimestamp');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (196, 31, 'MAKEDATE', 'Syntax\n------\n\nMAKEDATE(year,dayofyear)\n\nDescription\n-----------\n\nReturns a date, given year and day-of-year values. dayofyear must be greater than 0 or the result is NULL.\n\nExamples\n--------\n\nSELECT MAKEDATE(2011,31), MAKEDATE(2011,32);\n+-------------------+-------------------+\n| MAKEDATE(2011,31) | MAKEDATE(2011,32) |\n+-------------------+-------------------+\n| 2011-01-31        | 2011-02-01        |\n+-------------------+-------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/makedate', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/makedate');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (197, 31, 'MAKETIME', 'Syntax\n------\n\nMAKETIME(hour,minute,second)\n\nDescription\n-----------\n\nReturns a time value calculated from the hour, minute, and second arguments.\n\nIf minute or second are out of the range 0 to 60, NULL is returned. The hour can be in the range -838 to 838, outside of which the value is truncated with a warning.\n\nExamples\n--------\n\nSELECT MAKETIME(13,57,33);\n+--------------------+\n| MAKETIME(13,57,33) |\n+--------------------+\n| 13:57:33           |\n+--------------------+\n\nSELECT MAKETIME(-13,57,33);\n+---------------------+\n| MAKETIME(-13,57,33) |\n+---------------------+\n| -13:57:33           |\n+---------------------+\n\nSELECT MAKETIME(13,67,33);\n+--------------------+\n| MAKETIME(13,67,33) |\n+--------------------+\n| NULL               |\n+--------------------+\n\nSELECT MAKETIME(-1000,57,33);\n+-----------------------+\n| MAKETIME(-1000,57,33) |\n+-----------------------+\n| -838:59:59            |\n+-----------------------+\n1 row in set, 1 warning (0.00 sec)\n\nSHOW WARNINGS;\n+---------+------+-----------------------------------------------+\n| Level   | Code | Message                                       |\n+---------+------+-----------------------------------------------+\n| Warning | 1292 | Truncated incorrect time value: ''-1000:57:33'' |\n+---------+------+-----------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/maketime', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/maketime');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (198, 31, 'MICROSECOND', 'Syntax\n------\n\nMICROSECOND(expr)\n\nDescription\n-----------\n\nReturns the microseconds from the time or datetime expression _expr_ as a number in the range from 0 to 999999.\n\nIf _expr_ is a time with no microseconds, zero is returned, while if _expr_ is a date with no time, zero with a warning is returned.\n\nExamples\n--------\n\nSELECT MICROSECOND(''12:00:00.123456'');\n+--------------------------------+\n| MICROSECOND(''12:00:00.123456'') |\n+--------------------------------+\n|                         123456 |\n+--------------------------------+\n\nSELECT MICROSECOND(''2009-12-31 23:59:59.000010'');\n+-------------------------------------------+\n| MICROSECOND(''2009-12-31 23:59:59.000010'') |\n+-------------------------------------------+\n|                                        10 |\n+-------------------------------------------+\n\nSELECT MICROSECOND(''2013-08-07 12:13:14'');\n+------------------------------------+\n| MICROSECOND(''2013-08-07 12:13:14'') |\n+------------------------------------+\n|                                  0 |\n+------------------------------------+\n\nSELECT MICROSECOND(''2013-08-07'');\n+---------------------------+\n| MICROSECOND(''2013-08-07'') |\n+---------------------------+\n|                         0 |\n+---------------------------+\n1 row in set, 1 warning (0.00 sec)\n\nSHOW WARNINGS;\n+---------+------+----------------------------------------------+\n| Level   | Code | Message                                      |\n+---------+------+----------------------------------------------+\n| Warning | 1292 | Truncated incorrect time value: ''2013-08-07'' |\n+---------+------+----------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/microsecond', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/microsecond');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (199, 31, 'Microseconds in MariaDB', 'Description\n-----------\n\nThe TIME, DATETIME, and TIMESTAMP types, along with the temporal functions, CAST and dynamic columns, support microseconds. The datetime precision of a column can be specified when creating the table with CREATE TABLE, for example:\n\n``sql\nCREATE TABLE example(\n  col_microsec DATETIME(6),\n  col_millisec TIME(3)\n);\n`\n\nGenerally, the precision can be specified for any TIME, DATETIME, or TIMESTAMP column, in parentheses, after the type name. The datetime precision specifies number of digits after the decimal dot and can be any integer number from 0 to 6. If no precision is specified it is assumed to be 0, for backward compatibility reasons.\n\nA datetime precision can be specified wherever a type name is used. For example:\n\n when declaring arguments of stored routines;\n when specifying a return type of a stored function;\n when declaring variables;\n in a CAST function.\n\n`sql\nCREATE FUNCTION example(x DATETIME(5)) RETURNS TIME(4)\nBEGIN\n DECLARE y TIMESTAMP(6);\n RETURN CAST(x AS time(2));\nEND;\n`\n\n%f is used as the formatting option for microseconds in the STR_TO_DATE, DATE_FORMAT and FROM_UNIXTIME functions, for example:\n\n`sql\nSELECT STR_TO_DATE(''20200809 020917076'',''%Y%m%d %H%i%s%f'');\n+-----------------------------------------------------+\n| STR_TO_DATE(''20200809 020917076'',''%Y%m%d %H%i%s%f'') |\n+-----------------------------------------------------+\n| 2020-08-09 02:09:17.076000                          |\n+-----------------------------------------------------+\n`\n\nAdditional Information\n\n When comparing anything to a temporal value (DATETIME, TIME, DATE, or TIMESTAMP), both values are compared as temporal values, not as strings.\n The INFORMATION_SCHEMA.COLUMNS table has a new column DATETIME_PRECISION\n NOW(), CURTIME(), UTC_TIMESTAMP(), UTC_TIME(), CURRENT_TIME(), CURRENT_TIMESTAMP(), LOCALTIME() and LOCALTIMESTAMP() accept datetime precision as an optional argument. For example:\n\n`sql\nSELECT CURTIME(4);\n--> 10:11:12.3456\n`\n\n TIME_TO_SEC() and UNIX_TIMESTAMP() preserve microseconds of the argument. These functions will return a decimal number if the result non-zero datetime precision and an integer otherwise (for backward compatibility).\n\n`sql\nSELECT TIME_TO_SEC(''10:10:10.12345'');\n--> 36610.12345\n`\n\n Current versions of this patch fix a bug in the following optimization: In certain queries with DISTINCT MariaDB can ignore this clause if it can prove that all result rows are unique anyway, for example, when a primary key is compared with a constant. Sometimes this optimization was applied incorrectly, though — for example, when comparing a string with a date constant. This is now fixed.\n DATE_ADD() and DATE_SUB() functions can now take a TIME expression as an argument (not just DATETIME as before).\n\n`sql\nSELECT TIME(''10:10:10'') + INTERVAL 100 MICROSECOND;\n--> 10:10:10.000100\n`\n\n The event_time field in the mysql.general_log table and the start_time, query_time, and lock_time fields in the mysql.slow_log table now store values with microsecond precision.\n The old syntax TIMESTAMP(N), where N is the display width, is no longer supported.\n When a DATETIME value is compared to a TIME value, the latter is treated as a full datetime with a zero date part, similar to comparing DATE to a DATETIME, or to comparing DECIMAL numbers.\\\n  Earlier versions of MariaDB used to compare only the time part of both operands in such a case.\n In MariaDB, an extra column TIME_MS has been added to the INFORMATION_SCHEMA.PROCESSLIST table, as well as to the output of SHOW FULL PROCESSLIST.\n\nNote: When you convert a temporal value to a value with a smaller precision, it will be truncated, not rounded. This is done to guarantee that the date part is not changed. For example:\n\n`sql\nSELECT CAST(''2009-12-31 23:59:59.998877'' AS DATETIME(3));\n-> 2009-12-31 23:59:59.998\n``\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/microseconds-in-mariadb', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/microseconds-in-mariadb');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (200, 31, 'MINUTE', 'Syntax\n------\n\nMINUTE(time)\n\nDescription\n-----------\n\nReturns the minute for _time_, in the range 0 to 59.\n\nExamples\n--------\n\nSELECT MINUTE(''2013-08-03 11:04:03'');\n+-------------------------------+\n| MINUTE(''2013-08-03 11:04:03'') |\n+-------------------------------+\n|                             4 |\n+-------------------------------+\n\n SELECT MINUTE (''23:12:50'');\n+---------------------+\n| MINUTE (''23:12:50'') |\n+---------------------+\n|                  12 |\n+---------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/minute', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/minute');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (201, 31, 'MONTH', 'Syntax\n------\n\nMONTH(date)\n\nDescription\n-----------\n\nReturns the month for date in the range 1 to 12 for January to December, or 0 for dates such as 0000-00-00 or 2008-00-00 that have a zero month part.\n\nExamples\n--------\n\nSELECT MONTH(''2019-01-03'');\n+---------------------+\n| MONTH(''2019-01-03'') |\n+---------------------+\n|                   1 |\n+---------------------+\n\nSELECT MONTH(''2019-00-03'');\n+---------------------+\n| MONTH(''2019-00-03'') |\n+---------------------+\n|                   0 |\n+---------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/month', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/month');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (202, 31, 'MONTHNAME', 'Syntax\n------\n\nMONTHNAME(date)\n\nDescription\n-----------\n\nReturns the full name of the month for date. The language used for the name is controlled by the value of the lc_time_names system variable. See server locale for more on the supported locales.\n\nExamples\n--------\n\nSELECT MONTHNAME(''2019-02-03'');\n+-------------------------+\n| MONTHNAME(''2019-02-03'') |\n+-------------------------+\n| February                |\n+-------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/monthname', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/monthname');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (203, 31, 'MONTHS\\_BETWEEN', 'Description\n-----------\n\nMONTHS_BETWEEN returns the number of months between dates two dates. If the first date given is later than the second date, the result is positive; otherwise, the result is negative. If both dates are the same days of the month, or both are last days of months, the result is always an integer. Otherwise, the fractional portion of the result based on a 31-day month is calculated, and considered the difference in time components between the dates.\n\nThe following example calculates the months between two dates:\n\n``sql\nSELECT MONTHS_BETWEEN\n       (TO_DATE(''02-02-1995'',''MM-DD-YYYY''),\n        TO_DATE(''01-01-1995'',''MM-DD-YYYY'') \n       );\n`\n\nThe result is 1.03225806`.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/months_between', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/months_between');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (204, 31, 'NOW', 'Syntax\n------\n\nNOW([precision])\nCURRENT_TIMESTAMP\nCURRENT_TIMESTAMP([precision])\nLOCALTIME, LOCALTIME([precision])\nLOCALTIMESTAMP\nLOCALTIMESTAMP([precision])\n\nDescription\n-----------\n\nReturns the current date and time as a value in YYYY-MM-DD HH:MM:SS or YYYYMMDDHHMMSS.uuuuuu format, depending on whether the function is used in a string or numeric context. The value is expressed in the current time zone.\n\nMariaDB starting with 11.7\n\nThese functions return SQL standard compliant types:\n\n NOW() and CURRENT_TIMESTAMP() return a TIMESTAMP value (analogous to the standard type TIMESTAMP WITH LOCAL TIME ZONE) which corresponds to the current point in time and is unambiguous around DST changes.\n LOCALTIMESTAMP returns a DATETIME value (analogous to the standard type TIMESTAMP WITHOUT TIME ZONE). Storing its result in a TIMESTAMP column can result in a data loss around DST changes.\n\nThese functions do not return SQL standard compliant types:\n\n NOW()\n CURRENT_TIMESTAMP()\n* LOCALTIMESTAMP\n\nThe optional _precision_ determines the microsecond precision. See Microseconds in MariaDB.\n\nNOW() (or its synonyms) can be used as the default value for TIMESTAMP columns as well as.\n\nWhen displayed in the INFORMATION_SCHEMA.COLUMNS table, a default CURRENT TIMESTAMP is displayed as current_timestamp() .\n\nChanging the timestamp system variable with a SET timestamp statement affects the value returned by NOW(), but not by SYSDATE().\n\nExamples\n--------\n\nSELECT NOW();\n+---------------------+\n| NOW()               |\n+---------------------+\n| 2010-03-27 13:13:25 |\n+---------------------+\n\nSELECT NOW() + 0;\n+-----------------------+\n| NOW() + 0             |\n+-----------------------+\n| 20100327131329.000000 |\n+-----------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/now', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/now');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (205, 31, 'PERIOD\\_ADD', 'Syntax\n------\n\nPERIOD_ADD(P,N)\n\nDescription\n-----------\n\nAdds N months to period P. P is in the format YYMM or YYYYMM, and is not a date value. If P contains a two-digit year, values from 00 to 69 are converted to from 2000 to 2069, while values from 70 are converted to 1970 upwards.\n\nReturns a value in the format YYYYMM.\n\nExamples\n--------\n\nSELECT PERIOD_ADD(200801,2);\n+----------------------+\n| PERIOD_ADD(200801,2) |\n+----------------------+\n|               200803 |\n+----------------------+\n\nSELECT PERIOD_ADD(6910,2);\n+--------------------+\n| PERIOD_ADD(6910,2) |\n+--------------------+\n|             206912 |\n+--------------------+\n\nSELECT PERIOD_ADD(7010,2);\n+--------------------+\n| PERIOD_ADD(7010,2) |\n+--------------------+\n|             197012 |\n+--------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/period_add', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/period_add');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (206, 31, 'PERIOD\\_DIFF', 'Syntax\n------\n\nPERIOD_DIFF(P1,P2)\n\nDescription\n-----------\n\nReturns the number of months between periods P1 and P2. P1 and P2 can be in the format YYMM or YYYYMM, and are not date values.\n\nIf P1 or P2 contains a two-digit year, values from 00 to 69 are converted to from 2000 to 2069, while values from 70 are converted to 1970 upwards.\n\nExamples\n--------\n\nSELECT PERIOD_DIFF(200802,200703);\n+----------------------------+\n| PERIOD_DIFF(200802,200703) |\n+----------------------------+\n|                         11 |\n+----------------------------+\n\nSELECT PERIOD_DIFF(6902,6803);\n+------------------------+\n| PERIOD_DIFF(6902,6803) |\n+------------------------+\n|                     11 |\n+------------------------+\n\nSELECT PERIOD_DIFF(7002,6803);\n+------------------------+\n| PERIOD_DIFF(7002,6803) |\n+------------------------+\n|                  -1177 |\n+------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/period_diff', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/period_diff');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (207, 31, 'QUARTER', 'Syntax\n------\n\nQUARTER(date)\n\nDescription\n-----------\n\nReturns the quarter of the year for date, in the range 1 to 4. Returns 0 if month contains a zero value, or NULL if the given value is not otherwise a valid date (zero values are accepted).\n\nExamples\n--------\n\nSELECT QUARTER(''2008-04-01'');\n+-----------------------+\n| QUARTER(''2008-04-01'') |\n+-----------------------+\n|                     2 |\n+-----------------------+\n\nSELECT QUARTER(''2019-00-01'');\n+-----------------------+\n| QUARTER(''2019-00-01'') |\n+-----------------------+\n|                     0 |\n+-----------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/quarter', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/quarter');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (208, 31, 'SEC\\_TO\\_TIME', 'Syntax\n------\n\nSEC_TO_TIME(seconds)\n\nDescription\n-----------\n\nReturns the seconds argument, converted to hours, minutes, and seconds, as a TIME value. The range of the result is constrained to that of the TIME data type. A warning occurs if the argument corresponds to a value outside that range.\n\nThe time will be returned in the format hh:mm:ss, or hhmmss if used in a numeric calculation.\n\nExamples\n--------\n\nSELECT SEC_TO_TIME(12414);\n+--------------------+\n| SEC_TO_TIME(12414) |\n+--------------------+\n| 03:26:54           |\n+--------------------+\n\nSELECT SEC_TO_TIME(12414)+0;\n+----------------------+\n| SEC_TO_TIME(12414)+0 |\n+----------------------+\n|                32654 |\n+----------------------+\n\nSELECT SEC_TO_TIME(9999999);\n+----------------------+\n| SEC_TO_TIME(9999999) |\n+----------------------+\n| 838:59:59            |\n+----------------------+\n1 row in set, 1 warning (0.00 sec)\n\nSHOW WARNINGS;\n+---------+------+-------------------------------------------+\n| Level   | Code | Message                                   |\n+---------+------+-------------------------------------------+\n| Warning | 1292 | Truncated incorrect time value: ''9999999'' |\n+---------+------+-------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/sec_to_time', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/sec_to_time');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (209, 31, 'SECOND', 'Syntax\n------\n\nSECOND(time)\n\nDescription\n-----------\n\nReturns the second for a given time (which can include microseconds), in the range 0 to 59, or NULL if not given a valid time value.\n\nExamples\n--------\n\nSELECT SECOND(''10:05:03'');\n+--------------------+\n| SECOND(''10:05:03'') |\n+--------------------+\n|                  3 |\n+--------------------+\n\nSELECT SECOND(''10:05:01.999999'');\n+---------------------------+\n| SECOND(''10:05:01.999999'') |\n+---------------------------+\n|                         1 |\n+---------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/second', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/second');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (210, 31, 'STR\\_TO\\_DATE', 'Syntax\n------\n\nSTR_TO_DATE(str,format)\n\nDescription\n-----------\n\nThis is the inverse of the DATE_FORMAT() function. It takes a string str and a format string format. STR_TO_DATE() returns aDATETIME value if the format string contains both date and time parts, or aDATE or TIME value if the string contains only date or time parts.\n\nThe date, time, or datetime values contained in str should be given in the format indicated by format. If str contains an illegal date, time, or datetime value, STR_TO_DATE() returns NULL. An illegal value also produces a warning.\n\nUnder specific SQL_MODE settings an error may also be generated if the str isn''t a valid date:\n\n ALLOW_INVALID_DATES\n NO_ZERO_DATE\n* NO_ZERO_IN_DATE\n\nThe options that can be used by STR_TO_DATE(), as well as its inverse DATE_FORMAT() and the FROM_UNIXTIME() function, are:\n\n| Option | Description                                                                                                                                                                       |\n| ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| %a     | Short weekday name in current locale (Variable lc_time_names). |\n| %b     | Short form month name in current locale. For locale en_US this is one of: Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov or Dec.                                                    |\n| %c     | Month with 1 or 2 digits.                                                                                                                                                         |\n| %D     | Day with English suffix ''th'', ''nd'', ''st'' or ''rd''''. (1st, 2nd, 3rd...).                                                                                                            |\n| %d     | Day with 2 digits.                                                                                                                                                                |\n| %e     | Day with 1 or 2 digits.                                                                                                                                                           |\n| %f     | Microseconds 6 digits.                                                                                                                              |\n| %H     | Hour with 2 digits between 00-23.                                                                                                                                                 |\n| %h     | Hour with 2 digits between 01-12.                                                                                                                                                 |\n| %I     | Hour with 2 digits between 01-12.                                                                                                                                                 |\n| %i     | Minute with 2 digits.                                                                                                                                                             |\n| %j     | Day of the year (001-366)                                                                                                                                                         |\n| %k     | Hour with 1 digits between 0-23.                                                                                                                                                  |\n| %l     | Hour with 1 digits between 1-12.                                                                                                                                                  |\n| %M     | Full month name in current locale (Variable lc_time_names).    |\n| %m     | Month with 2 digits.                                                                                                                                                              |\n| %p     | AM/PM according to current locale (Variable lc_time_names).    |\n| %r     | Time in 12 hour format, followed by AM/PM. Short for ''%I:%i:%S %p''.                                                                                                               |\n| %S     | Seconds with 2 digits.                                                                                                                                                            |\n| %s     | Seconds with 2 digits.                                                                                                                                                            |\n| %T     | Time in 24 hour format. Short for ''%H:%i:%S''.                                                                                                                                     |\n| %U     | Week number (00-53), when first day of the week is Sunday.                                                                                                                        |\n| %u     | Week number (00-53), when first day of the week is Monday.                                                                                                                        |\n| %V     | Week number (01-53), when first day of the week is Sunday. Used with %X.                                                                                                          |\n| %v     | Week number (01-53), when first day of the week is Monday. Used with %x.                                                                                                          |\n| %W     | Full weekday name in current locale (Variable lc_time_names).  |\n| %w     | Day of the week. 0 = Sunday, 6 = Saturday.                                                                                                                                        |\n| %X     | Year with 4 digits when first day of the week is Sunday. Used with %V.                                                                                                            |\n| %x     | Year with 4 digits when first day of the week is Monday. Used with %v.                                                                                                            |\n| %Y     | Year with 4 digits.                                                                                                                                                               |\n| %y     | Year with 2 digits.                                                                                                                                                               |\n| %#     | For str_to_date(), skip all numbers.                                                                                                                          |\n| %.     | For str_to_date(), skip all punctation characters.                                                                                                            |\n| %@     | For str_to_date(), skip all alpha characters.                                                                                                                 |\n| %%     | A literal % character.                                                                                                                                                            |\n\nExamples\n--------\n\nSELECT STR_TO_DATE(''Wednesday, June 2, 2014'', ''%W, %M %e, %Y'');\n+---------------------------------------------------------+\n| STR_TO_DATE(''Wednesday, June 2, 2014'', ''%W, %M %e, %Y'') |\n+---------------------------------------------------------+\n| 2014-06-02                                              |\n+---------------------------------------------------------+\n\nSELECT STR_TO_DATE(''Wednesday23423, June 2, 2014'', ''%W, %M %e, %Y'');\n+--------------------------------------------------------------+\n| STR_TO_DATE(''Wednesday23423, June 2, 2014'', ''%W, %M %e, %Y'') |\n+--------------------------------------------------------------+\n| NULL                                                         |\n+--------------------------------------------------------------+\n1 row in set, 1 warning (0.00 sec)\n\nSHOW WARNINGS;\n+---------+------+-----------------------------------------------------------------------------------+\n| Level   | Code | Message                                                                           |\n+---------+------+-----------------------------------------------------------------------------------+\n| Warning | 1411 | Incorrect datetime value: ''Wednesday23423, June 2, 2014'' for function str_to_date |\n+---------+------+-----------------------------------------------------------------------------------+\n\nSELECT STR_TO_DATE(''Wednesday23423, June 2, 2014'', ''%W%#, %M %e, %Y'');\n+----------------------------------------------------------------+\n| STR_TO_DATE(''Wednesday23423, June 2, 2014'', ''%W%#, %M %e, %Y'') |\n+----------------------------------------------------------------+\n| 2014-06-02                                                     |\n+----------------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/str_to_date', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/str_to_date');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (211, 31, 'SUBDATE', 'Syntax\n------\n\nSUBDATE(date,INTERVAL expr unit), SUBDATE(expr,days)\n\nDescription\n-----------\n\nWhen invoked with the INTERVAL form of the second argument, SUBDATE() is a synonym for DATE_SUB(). See Date and Time Units for a complete list of permitted units.\n\nThe second form allows the use of an integer value for days. In such cases, it is interpreted as the number of days to be subtracted from the date or datetime expression expr.\n\nExamples\n--------\n\nSELECT DATE_SUB(''2008-01-02'', INTERVAL 31 DAY);\n+-----------------------------------------+\n| DATE_SUB(''2008-01-02'', INTERVAL 31 DAY) |\n+-----------------------------------------+\n| 2007-12-02                              |\n+-----------------------------------------+\n\nSELECT SUBDATE(''2008-01-02'', INTERVAL 31 DAY);\n+----------------------------------------+\n| SUBDATE(''2008-01-02'', INTERVAL 31 DAY) |\n+----------------------------------------+\n| 2007-12-02                             |\n+----------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/subdate', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/subdate');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (212, 31, 'SUBTIME', 'Syntax\n------\n\nSUBTIME(expr1,expr2)\n\nDescription\n-----------\n\nSUBTIME() returns expr1 - expr2 expressed as a value in the same format as expr1. expr1 is a time or datetime expression, and expr2 is a time expression.\n\nExamples\n--------\n\nSELECT SUBTIME(''2007-12-31 23:59:59.999999'',''1 1:1:1.000002'');\n+--------------------------------------------------------+\n| SUBTIME(''2007-12-31 23:59:59.999999'',''1 1:1:1.000002'') |\n+--------------------------------------------------------+\n| 2007-12-30 22:58:58.999997                             |\n+--------------------------------------------------------+\n\nSELECT SUBTIME(''01:00:00.999999'', ''02:00:00.999998'');\n+-----------------------------------------------+\n| SUBTIME(''01:00:00.999999'', ''02:00:00.999998'') |\n+-----------------------------------------------+\n| -00:59:59.999999                              |\n+-----------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/subtime', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/subtime');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (213, 31, 'SYSDATE', 'Syntax\n------\n\nSYSDATE([precision])\n\nDescription\n-----------\n\nReturns the current date and time as a value in YYYY-MM-DD HH:MM:SS or YYYYMMDDHHMMSS.uuuuuu format, depending on whether the function is used in a string or numeric context.\n\nThe optional _precision_ determines the microsecond precision. See Microseconds in MariaDB.\n\nSYSDATE() returns the time at which it executes. This differs from the behavior for NOW(), which returns a constant time that indicates the time at which the statement began to execute. (Within a stored routine or trigger, NOW() returns the time at which the routine or triggering statement began to execute.)\n\nIn addition, changing the timestamp system variable with a SET timestamp statement affects the value returned by NOW() but not by SYSDATE(). This means that timestamp settings in the binary log have no effect on invocations of SYSDATE().\n\nBecause SYSDATE() can return different values even within the same statement, and is not affected by SET TIMESTAMP, it is non-deterministic and therefore unsafe for replication if statement-based binary logging is used. If that is a problem, you can use row-based logging, or start the server with the --sysdate-is-now mariadbd option to cause SYSDATE() to be an alias for NOW(). The non-deterministic nature of SYSDATE() also means that indexes cannot be used for evaluating expressions that refer to it, and that statements using the SYSDATE() function are unsafe for statement-based replication.\n\nExamples\n--------\n\nSELECT NOW(), SLEEP(2), NOW();\n+---------------------+----------+---------------------+\n| NOW()               | SLEEP(2) | NOW()               |\n+---------------------+----------+---------------------+\n| 2010-03-27 13:23:40 |        0 | 2010-03-27 13:23:40 |\n+---------------------+----------+---------------------+\n\nSELECT SYSDATE(), SLEEP(2), SYSDATE();\n+---------------------+----------+---------------------+\n| SYSDATE()           | SLEEP(2) | SYSDATE()           |\n+---------------------+----------+---------------------+\n| 2010-03-27 13:23:52 |        0 | 2010-03-27 13:23:54 |\n+---------------------+----------+---------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/sysdate', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/sysdate');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (214, 31, 'TIME\\_FORMAT', 'Syntax\n------\n\nTIME_FORMAT(time,format)\n\nDescription\n-----------\n\nThis is used like the DATE_FORMAT() function, but the format string may contain format specifiers only for hours, minutes, and seconds. Other specifiers produce a NULL value or 0.\n\nExamples\n--------\n\nSELECT TIME_FORMAT(''100:00:00'', ''%H %k %h %I %l'');\n+--------------------------------------------+\n| TIME_FORMAT(''100:00:00'', ''%H %k %h %I %l'') |\n+--------------------------------------------+\n| 100 100 04 04 4                            |\n+--------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/time_format', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/time_format');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (215, 31, 'TIME\\_TO\\_SEC', 'Syntax\n------\n\nTIME_TO_SEC(time)\n\nDescription\n-----------\n\nReturns the time argument, converted to seconds.\n\nThe value returned by TIME_TO_SEC is of type DOUBLE. The returned value preserves microseconds of the argument. See also Microseconds in MariaDB.\n\nExamples\n--------\n\nSELECT TIME_TO_SEC(''22:23:00'');\n+-------------------------+\n| TIME_TO_SEC(''22:23:00'') |\n+-------------------------+\n|                   80580 |\n+-------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/time_to_sec', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/time_to_sec');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (216, 31, 'TIMEDIFF', 'Syntax\n------\n\nTIMEDIFF(expr1,expr2)\n\nDescription\n-----------\n\nTIMEDIFF() returns expr1 - expr2 expressed as a time value. expr1 andexpr2 are time or date-and-time expressions, but both must be of the\\\nsame type.\n\nExamples\n--------\n\nSELECT TIMEDIFF(''2000:01:01 00:00:00'', ''2000:01:01 00:00:00.000001'');\n+---------------------------------------------------------------+\n| TIMEDIFF(''2000:01:01 00:00:00'', ''2000:01:01 00:00:00.000001'') |\n+---------------------------------------------------------------+\n| -00:00:00.000001                                              |\n+---------------------------------------------------------------+\n\nSELECT TIMEDIFF(''2008-12-31 23:59:59.000001'', ''2008-12-30 01:01:01.000002'');\n+----------------------------------------------------------------------+\n| TIMEDIFF(''2008-12-31 23:59:59.000001'', ''2008-12-30 01:01:01.000002'') |\n+----------------------------------------------------------------------+\n| 46:58:57.999999                                                      |\n+----------------------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/timediff', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/timediff');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (217, 31, 'TIMESTAMPADD', 'Syntax\n------\n\nTIMESTAMPADD(unit,interval,datetime_expr)\n\nDescription\n-----------\n\nAdds the integer expression interval to the date or datetime expression datetime_expr. The unit for interval is given by the unit argument, which should be one of the following values: MICROSECOND, SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, QUARTER, or YEAR.\n\nThe unit value may be specified using one of keywords as shown, or with a prefix of SQL_TSI_. For example, DAY and SQL_TSI_DAY both are allowed.\n\nExamples\n--------\n\nSELECT TIMESTAMPADD(MINUTE,1,''2003-01-02'');\n+-------------------------------------+\n| TIMESTAMPADD(MINUTE,1,''2003-01-02'') |\n+-------------------------------------+\n| 2003-01-02 00:01:00                 |\n+-------------------------------------+\n\nSELECT TIMESTAMPADD(WEEK,1,''2003-01-02'');\n+-----------------------------------+\n| TIMESTAMPADD(WEEK,1,''2003-01-02'') |\n+-----------------------------------+\n| 2003-01-09                        |\n+-----------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/timestampadd', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/timestampadd');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (218, 31, 'TIMESTAMPDIFF', 'Syntax\n------\n\nTIMESTAMPDIFF(unit,datetime_expr1,datetime_expr2)\n\nDescription\n-----------\n\nReturns datetime_expr2 - datetime_expr1, where datetime_expr1 anddatetime_expr2 are date or datetime expressions. One expression may be a date and the other a datetime; a date value is treated as a datetime having the time part ''00:00:00'' where necessary. The unit for the result (an integer) is given by the unit argument. The legal values for unit are the same as those listed in the description of the TIMESTAMPADD() function, that is, MICROSECOND, SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, QUARTER, or YEAR.\n\nTIMESTAMPDIFF can also be used to calculate age.\n\nExamples\n--------\n\nSELECT TIMESTAMPDIFF(MONTH,''2003-02-01'',''2003-05-01'');\n+------------------------------------------------+\n| TIMESTAMPDIFF(MONTH,''2003-02-01'',''2003-05-01'') |\n+------------------------------------------------+\n|                                              3 |\n+------------------------------------------------+\n\nSELECT TIMESTAMPDIFF(YEAR,''2002-05-01'',''2001-01-01'');\n+-----------------------------------------------+\n| TIMESTAMPDIFF(YEAR,''2002-05-01'',''2001-01-01'') |\n+-----------------------------------------------+\n|                                            -1 |\n+-----------------------------------------------+\n\nSELECT TIMESTAMPDIFF(MINUTE,''2003-02-01'',''2003-05-01 12:05:55'');\n+----------------------------------------------------------+\n| TIMESTAMPDIFF(MINUTE,''2003-02-01'',''2003-05-01 12:05:55'') |\n+----------------------------------------------------------+\n|                                                   128885 |\n+----------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/timestampdiff', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/timestampdiff');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (219, 31, 'TO\\_DATE', 'Syntax\n------\n\nTO_DATE(string_expression [DEFAULT string_expression ON CONVERSION ERROR],\n        format_string [,NLS_FORMAT_STRING])\n\nDescription\n-----------\n\nTO_DATE was added for Oracle support.\n\n format_string has the same format elements as TO_CHAR(), except a few elements that are not supported (see below). TO_DATE() returns a datetime value.\n The allowed separators are the same as for TO_CHAR(): space ( ), tab (\\t), and any of !, #, %, '', (, ), , +, -, ., /, :, ;, <, =, or >.\n & can be used if the next character is not a character in the a-z or A-Z range. text indicates a text string that is used verbatim in the format. You cannot use the double-quote (") as a separator.\n NLS_FORMAT_STRING supports these options: NLS_CALENDAR=GREGORIAN and NLS_DATE_LANGUAGE=_language_, where _language_ can be one of the following:\n   All MariaDB short locales, like en_AU.\n   The following Oracle language names: ALBANIAN, AMERICAN, ARABIC, BASQUE, BELARUSIAN, BRAZILIAN PORTUGUESE, BULGARIAN, CANADIAN FRENCH, CATALAN, CROATIAN, CYRILLIC SERBIAN, CZECH, DANISH, DUTCH, ENGLISH, ESTONIAN, FINNISH, FRENCH, GERMAN, GREEK, HEBREW, HINDI, HUNGARIAN, ICELANDIC, INDONESIAN, ITALIAN, JAPANESE, KANNADA, KOREAN, LATIN AMERICAN SPANISH, LATVIAN, LITHUANIAN, MACEDONIAN, MALAY, MEXICAN SPANISH, NORWEGIAN, POLISH, PORTUGUESE, ROMANIAN, RUSSIAN, SIMPLIFIED CHINESE, SLOVAK, SLOVENIAN, SPANISH, SWAHILI, SWEDISH, TAMIL, THAI, TRADITIONAL CHINESE, TURKISH, UKRAINIAN, VIETNAMESE\n\nSupported Format Elements\n\n AD – Anno Domini ("in the year of the Lord")\n AD_DOT – Anno Domini ("in the year of the Lord")&#x20;\n AM – Meridian indicator (before midday)\n AM_DOT – Meridian indicator (before midday)\n DAY – Name of day\n DD – Day (1-31)\n DDD – Day of year (1-336)\n DY – Abbreviated name of day\n FF[1-6] – Fractional seconds\n HH – Hour (1-12)\n HH12 – Hour (1-12)\n HH24 – Hour (0-23)\n MI – Minutes (0-59)\n MM – Month (1-12)\n MON – Abbreviated name of month\n MONTH – Name of Month\n PM – Meridian indicator (after midday)\n PM_DOT – Meridian indicator (after midday)\n RR – 20th century dates in the 21st century. 2 digits in the 50-99 range are assumed starting from the year 2000, and 0-49 is assumed from 1900.&#x20;\n RRRR – 20th century dates in the 21st century. 4 digits\n SS – Seconds\n SYYYY – Signed 4-digit year; MariaDB only supports positive years\n Y – 1-digit year\n YY – 2-digit year\n YYY – 3-digit year\n YYYY – 4 digit year\n\nIf no datetime is given, the current datetime is used. For example, if ''MM-DD HH-MM-SS'' is given, the current year is used. (This is Oracle behavior.)\n\nUnsupported Options\n\n BC, D, DL, DS, E, EE, FM, FX, RM, SSSSS, TS, TZD, TZH, TZR, X, and SY BC are not supported by MariaDB datetime.\n Most other formats do not make sense in a MariaDB context, as we return  datetime with fractions, not as a string.\n D (day-of-week) is not supported as it is not clear how it would map to MariaDB. This element depends on the NLS territory of the session.\n RR only works with 2-digit years. (In Oracle, RR may also work with 4-digit years in some context, but the rules are not clear.)\n\nExtensions and Differences Compared to Oracle\n\n MariaDB supports FF (fractional seconds). If FF[#] is used, TO_DATE  returns a datetime with # of subseconds. If FF is not used, a datetime is returned. A warning (but no error) is issued if the string contains more digits than specified with F(#].\n Names can be shortened to their unique prefixes. For example, both January and Ja work fine.\n No error is issued if the datetime string is shorter than format_string and the next unused character is not a number. This is useful to get a datetime from a mixed set of strings in datetime format. By contrast, Oracle gives an error if the datetime string is too short.\n MariaDB supports short locales as language names.\n NLS_DATE_FORMAT can use double-quote (") and single-quote ('') for quoting.\n* NLS_DATE_FORMAT must be a constant string. This is to ensure that the server knows which locale to use when executing the function.\n\nExamples\n--------\n\nSELECT TO_DATE(''February 5, 2026, 20:56'',''%Y-%m-%e'')\n+-----------------------------------------------+\n| TO_DATE(''February 5, 2026, 20:56'',''%Y-%m-%e'') |\n+-----------------------------------------------+\n| 2026-02-05                                    |\n+-----------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/to_date', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/to_date');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (220, 31, 'TO\\_DAYS', 'Syntax\n------\n\nTO_DAYS(date)\n\nDescription\n-----------\n\nGiven a date date, returns the number of days since the start of the current calendar (0000-00-00).\n\nThe function is not designed for use with dates before the advent of the Gregorian calendar in October 1582. Results are not reliable since it doesn''t account for the lost days when the calendar changed from the Julian calendar.\n\nThis is the converse of the FROM_DAYS() function.\n\nExamples\n--------\n\nSELECT TO_DAYS(''2007-10-07'');\n+-----------------------+\n| TO_DAYS(''2007-10-07'') |\n+-----------------------+\n|                733321 |\n+-----------------------+\n\nSELECT TO_DAYS(''0000-01-01'');\n+-----------------------+\n| TO_DAYS(''0000-01-01'') |\n+-----------------------+\n|                     1 |\n+-----------------------+\n\nSELECT TO_DAYS(950501);\n+-----------------+\n| TO_DAYS(950501) |\n+-----------------+\n|          728779 |\n+-----------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/to_days', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/to_days');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (221, 31, 'TO\\_SECONDS', 'Syntax\n------\n\nTO_SECONDS(expr)\n\nDescription\n-----------\n\nReturns the number of seconds from year 0 till expr, or NULL if expr is not a valid date or datetime.\n\nExamples\n--------\n\nSELECT TO_SECONDS(''2013-06-13'');\n+--------------------------+\n| TO_SECONDS(''2013-06-13'') |\n+--------------------------+\n|              63538300800 |\n+--------------------------+\n\nSELECT TO_SECONDS(''2013-06-13 21:45:13'');\n+-----------------------------------+\n| TO_SECONDS(''2013-06-13 21:45:13'') |\n+-----------------------------------+\n|                       63538379113 |\n+-----------------------------------+\n\nSELECT TO_SECONDS(NOW());\n+-------------------+\n| TO_SECONDS(NOW()) |\n+-------------------+\n|       63543530875 |\n+-------------------+\n\nSELECT TO_SECONDS(20130513);\n+----------------------+\n| TO_SECONDS(20130513) |\n+----------------------+\n|          63535622400 |\n+----------------------+\n1 row in set (0.00 sec)\n\nSELECT TO_SECONDS(130513);\n+--------------------+\n| TO_SECONDS(130513) |\n+--------------------+\n|        63535622400 |\n+--------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/to_seconds', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/to_seconds');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (222, 31, 'TRUNC', 'Syntax\n------\n\nTRUNC(date[,fmt])\n\nDescription\n-----------\n\nReturns a DATETIME truncated according to fmt.\n\nSupported formats:\n\nTruncate to day: DD, DDD, J\\\nTruncate to month: MM, MON, MONTH, RM\\\nTruncate to year: SYEAR, SYYYY, Y,YEAR, YY, YYY, YYYY\n\nExamples\n--------\n\nSELECT TRUNC(''2025-09-24 12:43'',''DD'');\n+--------------------------------+\n| TRUNC(''2025-09-24 12:43'',''DD'') |\n+--------------------------------+\n| 2025-09-24 00:00:00            |\n+--------------------------------+\n\nSELECT TRUNC(''2025-09-24 12:43'',''MM'');\n+--------------------------------+\n| TRUNC(''2025-09-24 12:43'',''MM'') |\n+--------------------------------+\n| 2025-09-01 00:00:00            |\n+--------------------------------+\n\nSELECT TRUNC(''2025-09-24 12:43'',''YY'');\n+--------------------------------+\n| TRUNC(''2025-09-24 12:43'',''YY'') |\n+--------------------------------+\n| 2025-01-01 00:00:00            |\n+--------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/trunc', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/trunc');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (223, 31, 'UNIX\\_TIMESTAMP', 'Syntax\n------\n\nUNIX_TIMESTAMP()\nUNIX_TIMESTAMP(date)\n\nDescription\n-----------\n\nIf called with no argument, returns a Unix timestamp (seconds since 1970-01-01 00:00:00 UTC) as an unsigned integer. If UNIX_TIMESTAMP() is called with a date argument, it returns the value of the argument as seconds since 1970-01-01 00:00:00 UTC. date may be a DATE string, a DATETIME string, a TIMESTAMP, or a number in the format YYMMDD or YYYYMMDD. The server interprets date as a value in the current time zone and converts it to an internal value in UTC. Clients can set their time zone as described in time zones.\n\nThe inverse function of UNIX_TIMESTAMP() is FROM_UNIXTIME()\n\nUNIX_TIMESTAMP() supports microseconds.\n\nTimestamps in MariaDB have a maximum value of 4294967295, equivalent to 2106-02-07 06:28:15. This is due to the underlying 32-bit limitation. Using the function on a timestamp beyond this will result in NULL being returned. Use DATETIME as a storage type if you require dates beyond this.\n\nTimestamps in MariaDB have a maximum value of 2147483647, equivalent to 2038-01-19 05:14:07. This is due to the underlying 32-bit limitation. Using the function on a timestamp beyond this will result in NULL being returned. Use DATETIME as a storage type if you require dates beyond this.\n\nError Handling\n\nReturns NULL for wrong arguments to UNIX_TIMESTAMP().\n\nExamples\n--------\n\nSELECT UNIX_TIMESTAMP();\n+------------------+\n| UNIX_TIMESTAMP() |\n+------------------+\n|       1269711082 |\n+------------------+\n\nSELECT UNIX_TIMESTAMP(''2007-11-30 10:30:19'');\n+---------------------------------------+\n| UNIX_TIMESTAMP(''2007-11-30 10:30:19'') |\n+---------------------------------------+\n|                     1196436619.000000 |\n+---------------------------------------+\n\nSELECT UNIX_TIMESTAMP("2007-11-30 10:30:19.123456");\n+----------------------------------------------+\n| unix_timestamp("2007-11-30 10:30:19.123456") |\n+----------------------------------------------+\n|                            1196411419.123456 |\n+----------------------------------------------+\n\nSELECT FROM_UNIXTIME(UNIX_TIMESTAMP(''2007-11-30 10:30:19''));\n+------------------------------------------------------+\n| FROM_UNIXTIME(UNIX_TIMESTAMP(''2007-11-30 10:30:19'')) |\n+------------------------------------------------------+\n| 2007-11-30 10:30:19.000000                           |\n+------------------------------------------------------+\n\nSELECT FROM_UNIXTIME(FLOOR(UNIX_TIMESTAMP(''2007-11-30 10:30:19'')));\n+-------------------------------------------------------------+\n| FROM_UNIXTIME(FLOOR(UNIX_TIMESTAMP(''2007-11-30 10:30:19''))) |\n+-------------------------------------------------------------+\n| 2007-11-30 10:30:19                                         |\n+-------------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/unix_timestamp', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/unix_timestamp');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (224, 31, 'UTC\\_DATE', 'Syntax\n------\n\nUTC_DATE, UTC_DATE()\n\nDescription\n-----------\n\nReturns the current UTC date as a value in YYYY-MM-DD or YYYYMMDD format, depending on whether the function is used in a string or numeric context.\n\nExamples\n--------\n\nSELECT UTC_DATE(), UTC_DATE() + 0;\n+------------+----------------+\n| UTC_DATE() | UTC_DATE() + 0 |\n+------------+----------------+\n| 2010-03-27 |       20100327 |\n+------------+----------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/utc_date', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/utc_date');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (225, 31, 'UTC\\_TIME', 'Syntax\n------\n\nUTC_TIME\nUTC_TIME([precision])\n\nDescription\n-----------\n\nReturns the current UTC time as a value in HH:MM:SS or HHMMSS.uuuuuu format, depending on whether the function is used in a string or numeric context.\n\nThe optional _precision_ determines the microsecond precision. See Microseconds in MariaDB.\n\nExamples\n--------\n\nSELECT UTC_TIME(), UTC_TIME() + 0;\n+------------+----------------+\n| UTC_TIME() | UTC_TIME() + 0 |\n+------------+----------------+\n| 17:32:34   |  173234.000000 |\n+------------+----------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/utc_time', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/utc_time');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (226, 31, 'UTC\\_TIMESTAMP', 'Syntax\n------\n\nUTC_TIMESTAMP\nUTC_TIMESTAMP([precision])\n\nDescription\n-----------\n\nReturns the current UTC date and time as a value in YYYY-MM-DD HH:MM:SS or YYYYMMDDHHMMSS.uuuuuu format, depending on whether the function is used in a string or numeric context.\n\nThe optional _precision_ determines the microsecond precision. See Microseconds in MariaDB.\n\nExamples\n--------\n\nSELECT UTC_TIMESTAMP(), UTC_TIMESTAMP() + 0;\n+---------------------+-----------------------+\n| UTC_TIMESTAMP()     | UTC_TIMESTAMP() + 0   |\n+---------------------+-----------------------+\n| 2010-03-27 17:33:16 | 20100327173316.000000 |\n+---------------------+-----------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/utc_timestamp', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/utc_timestamp');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (227, 31, 'WEEK', 'Syntax\n------\n\nWEEK(date[,mode])\n\nDescription\n-----------\n\nThis function returns the week number for date. The two-argument form ofWEEK() allows you to specify whether the week starts on Sunday or Monday and whether the return value should be in the range from 0 to 53 or from 1 to 53. If the mode argument is omitted, the value of the default_week_format system variable is used.\n\nModes\n\n| Mode | 1st day of week | Range | Week 1 is the 1st week with |\n| ---- | --------------- | ----- | --------------------------- |\n| 0    | Sunday          | 0-53  | a Sunday in this year       |\n| 1    | Monday          | 0-53  | more than 3 days this year  |\n| 2    | Sunday          | 1-53  | a Sunday in this year       |\n| 3    | Monday          | 1-53  | more than 3 days this year  |\n| 4    | Sunday          | 0-53  | more than 3 days this year  |\n| 5    | Monday          | 0-53  | a Monday in this year       |\n| 6    | Sunday          | 1-53  | more than 3 days this year  |\n| 7    | Monday          | 1-53  | a Monday in this year       |\n\nWith the mode value of 3, which means ''more than 3 days this year'', weeks are numbered according to ISO 8601:1988.\n\nExamples\n--------\n\nSELECT WEEK(''2008-02-20'');\n+--------------------+\n| WEEK(''2008-02-20'') |\n+--------------------+\n|                  7 |\n+--------------------+\n\nSELECT WEEK(''2008-02-20'',0);\n+----------------------+\n| WEEK(''2008-02-20'',0) |\n+----------------------+\n|                    7 |\n+----------------------+\n\nSELECT WEEK(''2008-02-20'',1);\n+----------------------+\n| WEEK(''2008-02-20'',1) |\n+----------------------+\n|                    8 |\n+----------------------+\n\nSELECT WEEK(''2008-12-31'',0);\n+----------------------+\n| WEEK(''2008-12-31'',0) |\n+----------------------+\n|                   52 |\n+----------------------+\n\nSELECT WEEK(''2008-12-31'',1);\n+----------------------+\n| WEEK(''2008-12-31'',1) |\n+----------------------+\n|                   53 |\n+----------------------+\n\n SELECT WEEK(''2019-12-30'',3);\n+----------------------+\n| WEEK(''2019-12-30'',3) |\n+----------------------+\n|                    1 |\n+----------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/week', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/week');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (228, 31, 'WEEKDAY', 'Syntax\n------\n\nWEEKDAY(date)\n\nDescription\n-----------\n\nReturns the weekday index for date (0 = Monday, 1 = Tuesday, ... 6 = Sunday).\n\nThis contrasts with DAYOFWEEK() which follows the ODBC standard (1 = Sunday, 2 = Monday, ..., 7 = Saturday).\n\nExamples\n--------\n\nSELECT WEEKDAY(''2008-02-03 22:23:00'');\n+--------------------------------+\n| WEEKDAY(''2008-02-03 22:23:00'') |\n+--------------------------------+\n|                              6 |\n+--------------------------------+\n\nSELECT WEEKDAY(''2007-11-06'');\n+-----------------------+\n| WEEKDAY(''2007-11-06'') |\n+-----------------------+\n|                     1 |\n+-----------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/weekday', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/weekday');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (229, 31, 'WEEKOFYEAR', 'Syntax\n------\n\nWEEKOFYEAR(date)\n\nDescription\n-----------\n\nReturns the calendar week of the date as a number in the range from 1 sqto 53. WEEKOFYEAR() is a compatibility function that is equivalent to WEEK(date,3).\n\nExamples\n--------\n\nSELECT WEEKOFYEAR(''2008-02-20'');\n+--------------------------+\n| WEEKOFYEAR(''2008-02-20'') |\n+--------------------------+\n|                        8 |\n+--------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/weekofyear', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/weekofyear');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (230, 31, 'YEAR', 'Syntax\n------\n\nYEAR(date)\n\nDescription\n-----------\n\nReturns the year for the given date, in the range 1000 to 9999, or 0 for the "zero" date.\n\nSQL_TSI_YEAR is a synonym for YEAR:\n\nExamples\n--------\n\nCREATE TABLE t1 (d DATETIME);\nINSERT INTO t1 VALUES\n    ("2007-01-30 21:31:07"),\n    ("1983-10-15 06:42:51"),\n    ("2011-04-21 12:34:56"),\n    ("2011-10-30 06:31:41"),\n    ("2011-01-30 14:03:25"),\n    ("2004-10-07 11:19:34");\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/year', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/year');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (231, 31, 'YEARWEEK', 'Syntax\n------\n\nYEARWEEK(date), YEARWEEK(date,mode)\n\nDescription\n-----------\n\nReturns year and week for a date. The mode argument works exactly like the mode argument to WEEK(). The year in the result may be different from the year in the date argument for the first and the last week of the year.\n\nExamples\n--------\n\nSELECT YEARWEEK(''1987-01-01'');\n+------------------------+\n| YEARWEEK(''1987-01-01'') |\n+------------------------+\n|                 198652 |\n+------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/yearweek', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/yearweek');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (232, 35, 'Functions & Operators', 'Description\n-----------\n\n| Name                                                                                                                                    | Description                                                                                                               | Added                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |\n| --------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| +                                                               | Addition operator                                                                                                         |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |\n| /                                                               | Division operator                                                                                                         |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |\n| \\*                                                        | Multiplication operator                                                                                                   |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |\n| %                                                                 | Modulo operator. Returns the remainder of N divided by M                                                                  |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |\n| -                                                            | Subtraction operator                                                                                                      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |\n| !=                                                                      | Not equals                                                                                                                |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |\n| <                                                                       | Less than                                                                                                                 |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |\n| <=                                                             | Less than or equal                                                                                                        |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |\n| <=>                                                               | NULL-safe equal                                                                                                           |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |\n| =                                                                           | Equal                                                                                                                     |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |\n| >                                                                    | Greater than                                                                                                              |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |\n| >=                                                          | Greater than or equal                                                                                                     |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |\n| &                                                                     | Bitwise AND                                                                                                               |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |\n| <<                                                                     | Shift left                                                                                                                |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |\n| >>                                                                    | Shift right                                                                                                               |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |\n| ^                                                                     | Bitwise XOR                                                                                                               |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |\n| !                                                                                | Logical NOT                                                                                                               |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |\n| &&                                                                               | Logical AND                                                                                                               |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |\n| XOR\n\n[Truncated — full content at mariadb.com/docs]', '', 'https://mariadb.com/docs/server/reference/sql-functions/function-and-operator-reference');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (233, 4, 'ABS', 'Syntax\n------\n\nABS(X)\n\nDescription\n-----------\n\nReturns the absolute (non-negative) value of X. If X is not a number, it is converted to a numeric type.\n\nExamples\n--------\n\nSELECT ABS(42);\n+---------+\n| ABS(42) |\n+---------+\n|      42 |\n+---------+\n\nSELECT ABS(-42);\n+----------+\n| ABS(-42) |\n+----------+\n|       42 |\n+----------+\n\nSELECT ABS(DATE ''1994-01-01'');\n+------------------------+\n| ABS(DATE ''1994-01-01'') |\n+------------------------+\n|               19940101 |\n+------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/abs', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/abs');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (234, 4, 'ACOS', 'Syntax\n------\n\nACOS(X)\n\nDescription\n-----------\n\nReturns the arc cosine of X, that is, the value whose cosine is X. Returns NULL if X is not in the range -1 to 1.\n\nExamples\n--------\n\nSELECT ACOS(1);\n+---------+\n| ACOS(1) |\n+---------+\n|       0 |\n+---------+\n\nSELECT ACOS(1.0001);\n+--------------+\n| ACOS(1.0001) |\n+--------------+\n|         NULL |\n+--------------+\n\nSELECT ACOS(0);\n+-----------------+\n| ACOS(0)         |\n+-----------------+\n| 1.5707963267949 |\n+-----------------+\n\nSELECT ACOS(0.234);\n+------------------+\n| ACOS(0.234)      |\n+------------------+\n| 1.33460644244679 |\n+------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/acos', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/acos');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (235, 4, 'ASIN', 'Syntax\n------\n\nASIN(X)\n\nDescription\n-----------\n\nReturns the arc sine of X, that is, the value whose sine is X. Returns NULL if X is not in the range -1 to 1.\n\nExamples\n--------\n\nSELECT ASIN(0.2);\n+--------------------+\n| ASIN(0.2)          |\n+--------------------+\n| 0.2013579207903308 |\n+--------------------+\n\nSELECT ASIN(''foo'');\n+-------------+\n| ASIN(''foo'') |\n+-------------+\n|           0 |\n+-------------+\n\nSHOW WARNINGS;\n+---------+------+-----------------------------------------+\n| Level   | Code | Message                                 |\n+---------+------+-----------------------------------------+\n| Warning | 1292 | Truncated incorrect DOUBLE value: ''foo'' |\n+---------+------+-----------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/asin', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/asin');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (236, 4, 'ATAN', 'Syntax\n------\n\nATAN(X)\n\nDescription\n-----------\n\nReturns the arc tangent of X, that is, the value whose tangent is X.\n\nExamples\n--------\n\nSELECT ATAN(2);\n+--------------------+\n| ATAN(2)            |\n+--------------------+\n| 1.1071487177940904 |\n+--------------------+\n\nSELECT ATAN(-2);\n+---------------------+\n| ATAN(-2)            |\n+---------------------+\n| -1.1071487177940904 |\n+---------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/atan', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/atan');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (237, 4, 'ATAN2', 'Syntax\n------\n\nATAN(Y,X), ATAN2(Y,X)\n\nDescription\n-----------\n\nReturns the arc tangent of the two variables X and Y. It is similar to calculating the arc tangent of Y / X, except that the signs of both arguments are used to determine the quadrant of the result.\n\nExamples\n--------\n\nSELECT ATAN(-2,2);\n+---------------------+\n| ATAN(-2,2)          |\n+---------------------+\n| -0.7853981633974483 |\n+---------------------+\n\nSELECT ATAN2(PI(),0);\n+--------------------+\n| ATAN2(PI(),0)      |\n+--------------------+\n| 1.5707963267948966 |\n+--------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/atan2', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/atan2');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (238, 4, 'CEIL', 'Syntax\n------\n\nCEIL(X)\n\nDescription\n-----------\n\nCEIL() is a synonym for CEILING().\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/ceil', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/ceil');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (239, 4, 'CEILING', 'Syntax\n------\n\nCEILING(X)\n\nDescription\n-----------\n\nReturns the smallest integer value not less than X.\n\nExamples\n--------\n\nSELECT CEILING(1.23);\n+---------------+\n| CEILING(1.23) |\n+---------------+\n|             2 |\n+---------------+\n\nSELECT CEILING(-1.23);\n+----------------+\n| CEILING(-1.23) |\n+----------------+\n|             -1 |\n+----------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/ceiling', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/ceiling');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (240, 4, 'CONV', 'Syntax\n------\n\nCONV(N,from_base,to_base)\n\nDescription\n-----------\n\nConverts numbers between different number bases. Returns a string representation of the number _N_, converted from base _from_base_ to base _to_base_.\n\nReturns NULL if any argument is NULL, or if the second or third argument are not in the allowed range.\n\nThe argument _N_ is interpreted as an integer, but may be specified as an integer or a string. The minimum base is 2 and the maximum base is 62. If _to_base_ is a negative number, _N_ is regarded as a signed number. Otherwise, _N_ is treated as unsigned. CONV() works with 64-bit precision.\n\nThe argument _N_ is interpreted as an integer, but may be specified as an integer or a string. The minimum base is 2 and the maximum base is 36. If _to_base_ is a negative number, _N_ is regarded as a signed number. Otherwise, _N_ is treated as unsigned. CONV() works with 64-bit precision.\n\nSome shortcuts for this function are also available: BIN(), OCT(), HEX(), UNHEX(). Also, MariaDB allows binary literal values and hexadecimal literal values.\n\nExamples\n--------\n\nSELECT CONV(''a'',16,2);\n+----------------+\n| CONV(''a'',16,2) |\n+----------------+\n| 1010           |\n+----------------+\n\nSELECT CONV(''6E'',18,8);\n+-----------------+\n| CONV(''6E'',18,8) |\n+-----------------+\n| 172             |\n+-----------------+\n\nSELECT CONV(-17,10,-18);\n+------------------+\n| CONV(-17,10,-18) |\n+------------------+\n| -H               |\n+------------------+\n\nSELECT CONV(12+''10''+''10''+0xa,10,10);\n+------------------------------+\n| CONV(12+''10''+''10''+0xa,10,10) |\n+------------------------------+\n| 42                           |\n+------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/conv', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/conv');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (241, 4, 'COS', 'Syntax\n------\n\nCOS(X)\n\nDescription\n-----------\n\nReturns the cosine of X, where X is given in radians.\n\nExamples\n--------\n\nSELECT COS(PI());\n+-----------+\n| COS(PI()) |\n+-----------+\n|        -1 |\n+-----------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/cos', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/cos');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (242, 4, 'COT', 'Syntax\n------\n\nCOT(X)\n\nDescription\n-----------\n\nReturns the cotangent of X.\n\nExamples\n--------\n\nSELECT COT(42);\n+--------------------+\n| COT(42)            |\n+--------------------+\n| 0.4364167060752729 |\n+--------------------+\n\nSELECT COT(12);\n+---------------------+\n| COT(12)             |\n+---------------------+\n| -1.5726734063976893 |\n+---------------------+\n\nSELECT COT(0);\nERROR 1690 (22003): DOUBLE value is out of range in ''cot(0)''\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/cot', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/cot');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (243, 4, 'CRC32', 'Syntax\n------\n\nCRC32([par,]expr)\n\nDescription\n-----------\n\nComputes a cyclic redundancy check (CRC) value and returns a 32-bit unsigned value. The result is NULL if the argument is NULL. The argument is expected to be a string and (if possible) is treated as one if it is not.\n\nUses the alternate Castagnoli polynomia.\n\nOften, CRC is computed in pieces. To facilitate this, there''s an optional parameter: CRC32(''MariaDB'')=CRC32(CRC32(''Maria''),''DB'').\n\nUses the ISO 3309 polynomial that used by zlib and many others.\n\nExamples\n--------\n\nSELECT CRC32(CRC32(''Maria''),''DB'');\n+----------------------------+\n| CRC32(CRC32(''Maria''),''DB'') |\n+----------------------------+\n|                 4227209140 |\n+----------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/crc32', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/crc32');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (244, 4, 'CRC32C', 'Syntax\n------\n\nCRC32C([par,]expr)\n\nDescription\n-----------\n\nMariaDB has always included a native unary function CRC32() that computes the CRC-32 of a string using the ISO 3309 polynomial that used by zlib and many others.\n\nInnoDB and MyRocks use a different polynomial, which was implemented in SSE4.2 instructions that were introduced in the Intel Nehalem microarchitecture. This is commonly called CRC-32C (Castagnoli).\n\nThe CRC32C function uses the Castagnoli polynomial.\n\nThis allows SELECT…INTO DUMPFILE to be used for the creation of files with valid checksums, such as a logically empty InnoDB redo log fileib_logfile0 corresponding to a particular log sequence number.\n\nThe optional parameter allows the checksum to be computed in pieces:\\\nCRC32C(''MariaDB'')=CRC32C(CRC32C(''Maria''),''DB'').\n\nExamples\n--------\n\nSELECT CRC32C(''MariaDB'');\n+-------------------+\n| CRC32C(''MariaDB'') |\n+-------------------+\n|         809606978 |\n+-------------------+\n\nSELECT CRC32C(CRC32C(''Maria''),''DB'');\n+------------------------------+\n| CRC32C(CRC32C(''Maria''),''DB'') |\n+------------------------------+\n|                    809606978 |\n+------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/crc32c', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/crc32c');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (245, 4, 'DEGREES', 'Syntax\n------\n\nDEGREES(X)\n\nDescription\n-----------\n\nReturns the argument _X_, converted from radians to degrees.\n\nThis is the converse of the RADIANS() function.\n\nExamples\n--------\n\nSELECT DEGREES(PI());\n+---------------+\n| DEGREES(PI()) |\n+---------------+\n|           180 |\n+---------------+\n\nSELECT DEGREES(PI() / 2);\n+-------------------+\n| DEGREES(PI() / 2) |\n+-------------------+\n|                90 |\n+-------------------+\n\nSELECT DEGREES(45);\n+-----------------+\n| DEGREES(45)     |\n+-----------------+\n| 2578.3100780887 |\n+-----------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/degrees', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/degrees');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (246, 4, 'DIV', 'Syntax\n------\n\nDIV\n\nDescription\n-----------\n\nInteger division. Similar to FLOOR(), but is safe with BIGINT values. Incorrect results may occur for non-integer operands that exceed the BIGINT range.\n\nIf the ERROR_ON_DIVISION_BY_ZERO SQL_MODE is used, a division by zero produces an error. Otherwise, it returns NULL.\n\nThe remainder of a division can be obtained using the MOD operator.\n\nExamples\n--------\n\nSELECT 300 DIV 7;\n+-----------+\n| 300 DIV 7 |\n+-----------+\n|        42 |\n+-----------+\n\nSELECT 300 DIV 0;\n+-----------+\n| 300 DIV 0 |\n+-----------+\n|      NULL |\n+-----------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/div', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/div');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (247, 4, 'EXP', 'Syntax\n------\n\nEXP(X)\n\nDescription\n-----------\n\nReturns the value of e (the base of natural logarithms) raised to the power of X. The inverse of this function is LOG() (using a single argument only) or LN().\n\nIf X is NULL, this function returns NULL.\n\nExamples\n--------\n\nSELECT EXP(2);\n+------------------+\n| EXP(2)           |\n+------------------+\n| 7.38905609893065 |\n+------------------+\n\nSELECT EXP(-2);\n+--------------------+\n| EXP(-2)            |\n+--------------------+\n| 0.1353352832366127 |\n+--------------------+\n\nSELECT EXP(0);\n+--------+\n| EXP(0) |\n+--------+\n|      1 |\n+--------+\n\nSELECT EXP(NULL);\n+-----------+\n| EXP(NULL) |\n+-----------+\n|      NULL |\n+-----------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/exp', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/exp');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (248, 4, 'FLOOR', 'Syntax\n------\n\nFLOOR(X)\n\nDescription\n-----------\n\nReturns the largest integer value not greater than X.\n\nExamples\n--------\n\nSELECT FLOOR(1.23);\n+-------------+\n| FLOOR(1.23) |\n+-------------+\n|           1 |\n+-------------+\n\nSELECT FLOOR(-1.23);\n+--------------+\n| FLOOR(-1.23) |\n+--------------+\n|           -2 |\n+--------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/floor', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/floor');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (249, 4, 'LN', 'Syntax\n------\n\nLN(X)\n\nDescription\n-----------\n\nReturns the natural logarithm of X; that is, the base-e logarithm of X. If X is less than or equal to 0, or NULL, then NULL is returned.\n\nThe inverse of this function is EXP().\n\nExamples\n--------\n\nSELECT LN(2);\n+-------------------+\n| LN(2)             |\n+-------------------+\n| 0.693147180559945 |\n+-------------------+\n\nSELECT LN(-2);\n+--------+\n| LN(-2) |\n+--------+\n|   NULL |\n+--------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/ln', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/ln');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (250, 4, 'LOG', 'Syntax\n------\n\nLOG(X), LOG(B,X)\n\nDescription\n-----------\n\nIf called with one parameter, this function returns the natural logarithm of X. If X is less than or equal to 0, then NULL is returned.\n\nIf called with two parameters, it returns the logarithm of X to the base B. If B is <= 1 or X <= 0, the function returns NULL.\n\nIf any argument is NULL, the function returns NULL.\n\nThe inverse of this function (when called with a single argument) is the EXP() function.\n\nExamples\n--------\n\nSELECT LOG(2);\n+-------------------+\n| LOG(2)            |\n+-------------------+\n| 0.693147180559945 |\n+-------------------+\n\nSELECT LOG(-2);\n+---------+\n| LOG(-2) |\n+---------+\n|    NULL |\n+---------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/log', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/log');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (251, 4, 'LOG10', 'Syntax\n------\n\nLOG10(X)\n\nDescription\n-----------\n\nReturns the base-10 logarithm of X.\n\nExamples\n--------\n\nSELECT LOG10(2);\n+-------------------+\n| LOG10(2)          |\n+-------------------+\n| 0.301029995663981 |\n+-------------------+\n\nSELECT LOG10(100);\n+------------+\n| LOG10(100) |\n+------------+\n|          2 |\n+------------+\n\nSELECT LOG10(-100);\n+-------------+\n| LOG10(-100) |\n+-------------+\n|        NULL |\n+-------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/log10', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/log10');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (252, 4, 'LOG2', 'Syntax\n------\n\nLOG2(X)\n\nDescription\n-----------\n\nReturns the base-2 logarithm of X.\n\nExamples\n--------\n\nSELECT LOG2(4398046511104);\n+---------------------+\n| LOG2(4398046511104) |\n+---------------------+\n|                  42 |\n+---------------------+\n\nSELECT LOG2(65536);\n+-------------+\n| LOG2(65536) |\n+-------------+\n|          16 |\n+-------------+\n\nSELECT LOG2(-100);\n+------------+\n| LOG2(-100) |\n+------------+\n|       NULL |\n+------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/log2', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/log2');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (253, 4, 'MOD', 'Syntax\n------\n\nMOD(N,M), N % M, N MOD M\n\nDescription\n-----------\n\nModulo operation. Returns the remainder of N divided by M. See also Modulo Operator.\n\nIf the ERROR_ON_DIVISION_BY_ZERO SQL_MODE is used, any number modulus zero produces an error. Otherwise, it returns NULL.\n\nThe integer part of a division can be obtained using DIV.\n\nExamples\n--------\n\nSELECT 1042 % 50;\n+-----------+\n| 1042 % 50 |\n+-----------+\n|        42 |\n+-----------+\n\nSELECT MOD(234, 10);\n+--------------+\n| MOD(234, 10) |\n+--------------+\n|            4 |\n+--------------+\n\nSELECT 253 % 7;\n+---------+\n| 253 % 7 |\n+---------+\n|       1 |\n+---------+\n\nSELECT MOD(29,9);\n+-----------+\n| MOD(29,9) |\n+-----------+\n|         2 |\n+-----------+\n\nSELECT 29 MOD 9;\n+----------+\n| 29 MOD 9 |\n+----------+\n|        2 |\n+----------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/mod', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/mod');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (254, 4, 'OCT', 'Syntax\n------\n\nOCT(N)\n\nDescription\n-----------\n\nReturns a string representation of the octal value of N, where N is a longlong (BIGINT) number. This is equivalent to CONV(N,10,8). Returns NULL if N is NULL.\n\nExamples\n--------\n\nSELECT OCT(34);\n+---------+\n| OCT(34) |\n+---------+\n| 42      |\n+---------+\n\nSELECT OCT(12);\n+---------+\n| OCT(12) |\n+---------+\n| 14      |\n+---------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/oct', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/oct');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (255, 4, 'PI', 'Syntax\n------\n\nPI()\n\nDescription\n-----------\n\nReturns the value of π (pi). The default number of decimal places displayed is six, but MariaDB uses the full double-precision value internally.\n\nExamples\n--------\n\nSELECT PI();\n+----------+\n| PI()     |\n+----------+\n| 3.141593 |\n+----------+\n\nSELECT PI()+0.0000000000000000000000;\n+-------------------------------+\n| PI()+0.0000000000000000000000 |\n+-------------------------------+\n|      3.1415926535897931159980 |\n+-------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/pi', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/pi');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (256, 4, 'POW', 'Syntax\n------\n\nPOW(X,Y)\n\nDescription\n-----------\n\nReturns the value of X raised to the power of Y.\n\nPOWER() is a synonym.\n\nExamples\n--------\n\nSELECT POW(2,3);\n+----------+\n| POW(2,3) |\n+----------+\n|        8 |\n+----------+\n\nSELECT POW(2,-2);\n+-----------+\n| POW(2,-2) |\n+-----------+\n|      0.25 |\n+-----------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/pow', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/pow');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (257, 4, 'POWER', 'Syntax\n------\n\nPOWER(X,Y)\n\nDescription\n-----------\n\nThis is a synonym for POW(), which returns the value of X raised to the power of Y.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/power', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/power');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (258, 4, 'RADIANS', 'Syntax\n------\n\nRADIANS(X)\n\nDescription\n-----------\n\nReturns the argument _X_, converted from degrees to radians. Note that π radians equals 180 degrees.\n\nThis is the converse of the DEGREES() function.\n\nExamples\n--------\n\nSELECT RADIANS(45);\n+-------------------+\n| RADIANS(45)       |\n+-------------------+\n| 0.785398163397448 |\n+-------------------+\n\nSELECT RADIANS(90);\n+-----------------+\n| RADIANS(90)     |\n+-----------------+\n| 1.5707963267949 |\n+-----------------+\n\nSELECT RADIANS(PI());\n+--------------------+\n| RADIANS(PI())      |\n+--------------------+\n| 0.0548311355616075 |\n+--------------------+\n\nSELECT RADIANS(180);\n+------------------+\n| RADIANS(180)     |\n+------------------+\n| 3.14159265358979 |\n+------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/radians', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/radians');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (259, 4, 'RAND', 'Description\n-----------\n\nReturns a random DOUBLE precision floating point value v in the range 0 <= v < 1.0. If a constant integer argument N is specified, it is used as the seed value, which produces a repeatable sequence of column values. In the example below, note that the sequences of values produced by RAND(3) is the same both places where it occurs.\n\nIn a WHERE clause, RAND() is evaluated each time the WHERE is executed.\n\nStatements using the RAND() function are not safe for statement-based replication.\n\nPractical uses\n\nThe expression to get a random integer from a given range is the following:\n\n``sql\nFLOOR(min_value + RAND()  (max_value - min_value +1))\n`\n\nRAND() is often used to read random rows from a table, as follows:\n\n`sql\nSELECT  FROM my_table ORDER BY RAND() LIMIT 10;\n`\n\nNote, however, that this technique should never be used on a large table as it will be extremely slow. MariaDB will read all rows in the table, generate a random value for each of them, order them, and finally will apply the LIMIT` clause.\n\nExamples\n--------\n\nCREATE TABLE t (i INT);\n\nINSERT INTO t VALUES(1),(2),(3);\n\nSELECT i, RAND() FROM t;\n+------+-------------------+\n| i    | RAND()            |\n+------+-------------------+\n|    1 | 0.255651095188829 |\n|    2 | 0.833920199269355 |\n|    3 |  0.40264774151393 |\n+------+-------------------+\n\nSELECT i, RAND(3) FROM t;\n+------+-------------------+\n| i    | RAND(3)           |\n+------+-------------------+\n|    1 |  0.90576975597606 |\n|    2 | 0.373079058130345 |\n|    3 | 0.148086053457191 |\n+------+-------------------+\n\nSELECT i, RAND() FROM t;\n+------+-------------------+\n| i    | RAND()            |\n+------+-------------------+\n|    1 | 0.511478140495232 |\n|    2 | 0.349447508668012 |\n|    3 | 0.212803152588013 |\n+------+-------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/rand', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/rand');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (260, 4, 'ROUND', 'Description\n-----------\n\nRounds the argument X to D decimal places. D defaults to 0 if not specified.D can be negative to cause D digits left of the decimal point of the value X to become zero.\n\nThe rounding algorithm depends on the data type of X:\n\n For floating-point types (FLOAT, DOUBLE) the C libraries rounding function is used, so the behavior _may_ differ between operating systems.\n For fixed-point types (DECIMAL, DEC/NUMBER/FIXED) the "round half up" rule is used, meaning that e.g. a value ending in exactly .5 is always rounded up.\n\nExamples\n--------\n\nSELECT ROUND(-1.23);\n+--------------+\n| ROUND(-1.23) |\n+--------------+\n|           -1 |\n+--------------+\n\nSELECT ROUND(-1.58);\n+--------------+\n| ROUND(-1.58) |\n+--------------+\n|           -2 |\n+--------------+\n\nSELECT ROUND(1.58); \n+-------------+\n| ROUND(1.58) |\n+-------------+\n|           2 |\n+-------------+\n\nSELECT ROUND(1.298, 1);\n+-----------------+\n| ROUND(1.298, 1) |\n+-----------------+\n|             1.3 |\n+-----------------+\n\nSELECT ROUND(1.298, 0);\n+-----------------+\n| ROUND(1.298, 0) |\n+-----------------+\n|               1 |\n+-----------------+\n\nSELECT ROUND(23.298, -1);\n+-------------------+\n| ROUND(23.298, -1) |\n+-------------------+\n|                20 |\n+-------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/round', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/round');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (261, 4, 'SIGN', 'Syntax\n------\n\nSIGN(X)\n\nDescription\n-----------\n\nReturns the sign of the argument as -1, 0, or 1, depending on whether X is negative, zero, or positive.\n\nExamples\n--------\n\nSELECT SIGN(-32);\n+-----------+\n| SIGN(-32) |\n+-----------+\n|        -1 |\n+-----------+\n\nSELECT SIGN(0);\n+---------+\n| SIGN(0) |\n+---------+\n|       0 |\n+---------+\n\nSELECT SIGN(234);\n+-----------+\n| SIGN(234) |\n+-----------+\n|         1 |\n+-----------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/sign', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/sign');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (262, 4, 'SIN', 'Syntax\n------\n\nSIN(X)\n\nDescription\n-----------\n\nReturns the sine of X, where X is given in radians.\n\nExamples\n--------\n\nSELECT SIN(1.5707963267948966);\n+-------------------------+\n| SIN(1.5707963267948966) |\n+-------------------------+\n|                       1 |\n+-------------------------+\n\nSELECT SIN(PI());\n+----------------------+\n| SIN(PI())            |\n+----------------------+\n| 1.22460635382238e-16 |\n+----------------------+\n\nSELECT ROUND(SIN(PI()));\n+------------------+\n| ROUND(SIN(PI())) |\n+------------------+\n|                0 |\n+------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/sin', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/sin');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (263, 4, 'SQRT', 'Syntax\n------\n\nSQRT(X)\n\nDescription\n-----------\n\nReturns the square root of X. If X is negative, NULL is returned.\n\nExamples\n--------\n\nSELECT SQRT(4);\n+---------+\n| SQRT(4) |\n+---------+\n|       2 |\n+---------+\n\nSELECT SQRT(20);\n+------------------+\n| SQRT(20)         |\n+------------------+\n| 4.47213595499958 |\n+------------------+\n\nSELECT SQRT(-16);\n+-----------+\n| SQRT(-16) |\n+-----------+\n|      NULL |\n+-----------+\n\nSELECT SQRT(1764);\n+------------+\n| SQRT(1764) |\n+------------+\n|         42 |\n+------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/sqrt', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/sqrt');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (264, 4, 'TAN', 'Syntax\n------\n\nTAN(X)\n\nDescription\n-----------\n\nReturns the tangent of X, where X is given in radians.\n\nExamples\n--------\n\nSELECT TAN(0.7853981633974483);\n+-------------------------+\n| TAN(0.7853981633974483) |\n+-------------------------+\n|      0.9999999999999999 |\n+-------------------------+\n\nSELECT TAN(PI());\n+-----------------------+\n| TAN(PI())             |\n+-----------------------+\n| -1.22460635382238e-16 |\n+-----------------------+\n\nSELECT TAN(PI()+1);\n+-----------------+\n| TAN(PI()+1)     |\n+-----------------+\n| 1.5574077246549 |\n+-----------------+\n\nSELECT TAN(RADIANS(PI()));\n+--------------------+\n| TAN(RADIANS(PI())) |\n+--------------------+\n| 0.0548861508080033 |\n+--------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/tan', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/tan');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (265, 4, 'TO\\_NUMBER', 'Syntax\n------\n\nTO_NUMBER(number_or_string_subject)\nTO_NUMBER(string_subject,string_format)\n\nDescription\n-----------\n\nThe function returns the DOUBLE data type for all signatures and input data types.\n\nThe format parser understands the following components:\n\n Digits: 0, 9\n Hex digits: X\n Group separators: comma (,) and G\n Decimal delimiters: period (.) and D\n Approximate number signature: EEEE\n Currency/numeric flags: $ and B\n Currency signatures: C, L, U\n Sign signatures: S, MI, PR\n Special format signatures: V, TM, TM9, TME\n Format flag: FM\n\nThe function was introduced for Oracle compatibility, but does not include the following features:\n\n The ON CONVERSION ERROR clause\n The third parameter (nlsparam)\n* Internationalized components: G, D, C, L, U\n\nThese features are planned to be be implemented via MDEV-36978.\n\nExamples\n--------\n\nSELECT TO_NUMBER(''100.00'');\n+---------------------+\n| TO_NUMBER(''100.00'') |\n+---------------------+\n|                 100 |\n+---------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/to_number', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/to_number');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (266, 4, 'TRUNCATE', 'Syntax\n------\n\nTRUNCATE(X,D)\n\nDescription\n-----------\n\nReturns the number X, truncated to D decimal places. If D is 0, the result has no decimal point or fractional part. D can be negative to cause D digits left of the decimal point of the value X to become\\\nzero.\n\nExamples\n--------\n\nSELECT TRUNCATE(1.223,1);\n+-------------------+\n| TRUNCATE(1.223,1) |\n+-------------------+\n|               1.2 |\n+-------------------+\n\nSELECT TRUNCATE(1.999,1);\n+-------------------+\n| TRUNCATE(1.999,1) |\n+-------------------+\n|               1.9 |\n+-------------------+\n\nSELECT TRUNCATE(1.999,0); \n+-------------------+\n| TRUNCATE(1.999,0) |\n+-------------------+\n|                 1 |\n+-------------------+\n\nSELECT TRUNCATE(-1.999,1);\n+--------------------+\n| TRUNCATE(-1.999,1) |\n+--------------------+\n|               -1.9 |\n+--------------------+\n\nSELECT TRUNCATE(122,-2);\n+------------------+\n| TRUNCATE(122,-2) |\n+------------------+\n|              100 |\n+------------------+\n\nSELECT TRUNCATE(10.28100,0);\n+-----------------------+\n| TRUNCATE(10.28100,0) |\n+-----------------------+\n|                  1028 |\n+-----------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/truncate', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/truncate');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (267, 35, '\\_rowid', 'Syntax\n------\n\n_rowid\n\nDescription\n-----------\n\nThe _rowid pseudo column is mapped to the primary key in the related table. This can be used as a replacement of the rowid pseudo column in other databases. Another usage is to simplify sql queries as one doesn''t have to know the name of the primary key.\n\nExamples\n--------\n\nCREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(80));\nINSERT INTO t1 VALUES (1,"one"),(2,"two");\nSELECT * FROM t1 WHERE _rowid=1;\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/pseudo-columns/_rowid', '', 'https://mariadb.com/docs/server/reference/sql-functions/pseudo-columns/_rowid');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (268, 19, 'BIT\\_COUNT', 'Syntax\n------\n\nBIT_COUNT(N)\n\nDescription\n-----------\n\nReturns the number of bits that are set in the argument N.\n\nExamples\n--------\n\nSELECT BIT_COUNT(29), BIT_COUNT(b''101010'');\n+---------------+----------------------+\n| BIT_COUNT(29) | BIT_COUNT(b''101010'') |\n+---------------+----------------------+\n|             4 |                    3 |\n+---------------+----------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/bit_count', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/bit_count');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (269, 19, '\\~', 'Syntax\n------\n\n~\n\nDescription\n-----------\n\nBitwise NOT. Converts the value to 4 bytes binary and inverts all bits.\n\nExamples\n--------\n\nSELECT 3 & ~1;\n+--------+\n| 3 & ~1 |\n+--------+\n|      2 |\n+--------+\n\nSELECT 5 & ~1;\n+--------+\n| 5 & ~1 |\n+--------+\n|      4 |\n+--------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/bitwise-not', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/bitwise-not');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (270, 19, '|', 'Syntax\n------\n\n|\n\nDescription\n-----------\n\nBitwise OR. Converts the values to binary and compares bits. If either of the corresponding bits has a value of 1, the resulting bit is also 1.\n\nSee also bitwise AND.\n\nExamples\n--------\n\nSELECT 2|1;\n+-----+\n| 2|1 |\n+-----+\n|   3 |\n+-----+\n\nSELECT 29 | 15;\n+---------+\n| 29 | 15 |\n+---------+\n|      31 |\n+---------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/bitwise-or', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/bitwise-or');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (271, 19, '^', 'Syntax\n------\n\n^\n\nDescription\n-----------\n\nBitwise XOR. Converts the values to binary and compares bits. If one (and only one) of the corresponding bits is 1 is the resulting bit also 1.\n\nExamples\n--------\n\nSELECT 1 ^ 1;\n+-------+\n| 1 ^ 1 |\n+-------+\n|     0 |\n+-------+\n\nSELECT 1 ^ 0;\n+-------+\n| 1 ^ 0 |\n+-------+\n|     1 |\n+-------+\n\nSELECT 11 ^ 3;\n+--------+\n| 11 ^ 3 |\n+--------+\n|      8 |\n+--------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/bitwise-xor', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/bitwise-xor');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (272, 19, '&', 'Syntax\n------\n\n&\n\nDescription\n-----------\n\nBitwise AND. Converts the values to binary and compares bits. Only if both the corresponding bits are 1 is the resulting bit also 1.\n\nSee also bitwise OR.\n\nExamples\n--------\n\nSELECT 2&1;\n+-----+\n| 2&1 |\n+-----+\n|   0 |\n+-----+\n\nSELECT 3&1;\n+-----+\n| 3&1 |\n+-----+\n|   1 |\n+-----+\n\nSELECT 29 & 15;\n+---------+\n| 29 & 15 |\n+---------+\n|      13 |\n+---------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/bitwise_and', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/bitwise_and');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (273, 19, 'Parentheses', 'Description\n-----------\n\nParentheses are sometimes called precedence operators - this means that they can be used to change the other operator''s precedence in an expression. The expressions that are written between parentheses are computed before the expressions that are written outside. Parentheses must always contain an expression (that is, they cannot be empty), and can be nested.\n\nFor example, the following expressions could return different results:\n\n NOT a OR b\n NOT (a OR b)\n\nIn the first case, NOT applies to a, so if a is FALSE or b is TRUE, the expression returns TRUE. In the second case, NOT applies to the result of a OR b, so if at least one of a or b is TRUE, the expression is TRUE.\n\nWhen the precedence of operators is not intuitive, you can use parentheses to make it immediately clear for whoever reads the statement.\n\nThe precedence of the NOT operator can also be affected by the HIGH_NOT_PRECEDENCE SQL_MODE flag.\n\nOther uses\n\nParentheses must always be used to enclose subqueries.\n\nParentheses can also be used in a JOIN statement between multiple tables to determine which tables must be joined first.\n\nAlso, parentheses are used to enclose the list of parameters to be passed to built-in functions, user-defined functions and stored routines. However, when no parameter is passed to a stored procedure, parentheses are optional. For builtin functions and user-defined functions, spaces are not allowed between the function name and the open parenthesis, unless the IGNORE_SPACE SQL_MODE is set. For stored routines (and for functions if IGNORE_SPACE is set) spaces are allowed before the open parenthesis, including tab characters and new line characters.\n\nSyntax errors\n\nIf there are more open parentheses than closed parentheses, the error usually looks like this:\n\n``sql\nERROR 1064 (42000): You have an error in your SQL syntax; check the manual that\ncorresponds to your MariaDB server version for the right syntax to use near '''' a\nt line 1\n`\n\nNote the empty string.\n\nIf there are more closed parentheses than open parentheses, the error usually looks like this:\n\n`sql\nERROR 1064 (42000): You have an error in your SQL syntax; check the manual that\ncorresponds to your MariaDB server version for the right syntax to use near '')''\nat line 1\n``\n\nNote the quoted closed parenthesis.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/parentheses', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/parentheses');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (274, 19, '<<', 'Syntax\n------\n\nvalue1 << value2\n\nDescription\n-----------\n\nConverts a longlong (BIGINT) number (_value1_) to binary and shifts _value2_ units to the left.\n\nExamples\n--------\n\nSELECT 1 << 2;\n+--------+\n| 1 << 2 |\n+--------+\n|      4 |\n+--------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/shift-left', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/shift-left');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (275, 19, '>>', 'Syntax\n------\n\nvalue1 >> value2\n\nDescription\n-----------\n\nConverts a longlong (BIGINT) number (_value1_) to binary and shifts _value2_ units to the right.\n\nExamples\n--------\n\nSELECT 4 >> 2;\n+--------+\n| 4 >> 2 |\n+--------+\n|      1 |\n+--------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/shift-right', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/shift-right');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (276, 19, 'TRUE FALSE', 'Description\n-----------\n\nThe constants TRUE and FALSE evaluate to 1 and 0, respectively. The constant names can be written in any lettercase.\n\nExamples\n--------\n\nSELECT TRUE, true, FALSE, false;\n+------+------+-------+-------+\n| TRUE | TRUE | FALSE | FALSE |\n+------+------+-------+-------+\n|    1 |    1 |     0 |     0 |\n+------+------+-------+-------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/true-false', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/true-false');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (277, 35, 'AES\\_DECRYPT', 'Syntax\n------\n\nAES_ENCRYPT(crypt_str, key_str, [, iv [, mode]])\n\nDescription\n-----------\n\nThis function allows decryption of data using the official AES (Advanced Encryption Standard) algorithm. For more information, see the description of AES_ENCRYPT().\n\nThe function supports an initialization vector, and control of the block encryption mode. The default mode is specified by the block_encryption_mode system variable, which can be changed when calling the function with a mode. _mode_ is aes-{128,192,256}-{ecb,cbc,ctr} for example: "AES-128-cbc".\n\nFor modes that require it, the initialization_vector _iv_ should be 16 bytes (it can be longer, but the extra bytes are ignored). A shorter _iv_, where one is required, results in the function returning NULL. Calling RANDOM_BYTES(16) will generate a random series of bytes that can be used for the _iv_.\n\nExamples\n\n``sql\nSELECT HEX(AES_ENCRYPT(''foo'', ''bar'', ''0123456789abcdef'', ''aes-128-ctr'')) AS x; \n+--------+\n| x      |\n+--------+\n| C57C4B |\n+--------+\n\nSELECT AES_DECRYPT(x''C57C4B'', ''bar'', ''0123456789abcdef'', ''aes-128-ctr''); \n+------------------------------------------------------------------+\n| AES_DECRYPT(x''C57C4B'', ''bar'', ''0123456789abcdef'', ''aes-128-ctr'') |\n+------------------------------------------------------------------+\n| foo                                                              |\n+------------------------------------------------------------------+\n``\n\nThe function does not support an initialization vector.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/aes_decrypt', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/aes_decrypt');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (278, 35, 'AES\\_ENCRYPT', 'Syntax\n------\n\nAES_ENCRYPT(str, key, [, iv [, mode]])\n\nDescription\n-----------\n\nAES_ENCRYPT() and AES_DECRYPT() allow encryption and decryption of data using the official AES (Advanced Encryption Standard) algorithm, previously known as "Rijndael." Encoding with a 128-bit key length is used (from MariaDB 11.2.0, this is the default, and can be changed). 128 bits is much faster and is secure enough for most purposes.\n\nAES_ENCRYPT() encrypts a string _str_ using the key _key_str_, and returns a binary string.\n\nAES_DECRYPT() decrypts the encrypted string and returns the original string.\n\nThe input arguments may be any length. If either argument is NULL, the result of this function is also NULL.\n\nBecause AES is a block-level algorithm, padding is used to encode uneven length strings and so the result string length may be calculated using this formula:\n\n``sql\n16 x (trunc(string_length / 16) + 1)\n`\n\nIf AES_DECRYPT() detects invalid data or incorrect padding, it returns NULL. However, it is possible for AES_DECRYPT() to return a non-NULL value (possibly garbage) if the input data or the key is invalid.\n\nMariaDB starting with 11.2\n\nThe function supports an initialization vector, and control of the block encryption mode. The default mode is specified by the block_encryption_mode system variable, which can be changed when calling the function with a mode. _mode_ is aes-{128,192,256}-{ecb,cbc,ctr} for example: "AES-128-cbc".\\\nAES_ENCRYPT(str, key)` can no longer be used in persistent virtual columns (and the like).\n\nThe function does not support an initialization vector.\n\nExamples\n--------\n\nSELECT HEX(AES_ENCRYPT(''foo'', ''bar'', ''0123456789abcdef'', ''aes-256-cbc'')) AS x;\n+----------------------------------+\n| x                                |\n+----------------------------------+\n| 42A3EB91E6DFC40A900D278F99E0726E |\n+----------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/aes_encrypt', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/aes_encrypt');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (279, 35, 'COMPRESS', 'Syntax\n------\n\nCOMPRESS(string_to_compress)\n\nDescription\n-----------\n\nCompresses a string and returns the result as a binary string. This function requires MariaDB to have been compiled with a compression library such as zlib. Otherwise, the return value is always NULL. The\\\ncompressed string can be uncompressed with UNCOMPRESS().\n\nThe have_compress server system variable indicates whether a compression library is present.\n\nExamples\n--------\n\nSELECT LENGTH(COMPRESS(REPEAT(''a'',1000)));\n+------------------------------------+\n| LENGTH(COMPRESS(REPEAT(''a'',1000))) |\n+------------------------------------+\n|                                 21 |\n+------------------------------------+\n\nSELECT LENGTH(COMPRESS(''''));\n+----------------------+\n| LENGTH(COMPRESS('''')) |\n+----------------------+\n|                    0 |\n+----------------------+\n\nSELECT LENGTH(COMPRESS(''a''));\n+-----------------------+\n| LENGTH(COMPRESS(''a'')) |\n+-----------------------+\n|                    13 |\n+-----------------------+\n\nSELECT LENGTH(COMPRESS(REPEAT(''a'',16)));\n+----------------------------------+\n| LENGTH(COMPRESS(REPEAT(''a'',16))) |\n+----------------------------------+\n|                               15 |\n+----------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/compress', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/compress');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (280, 35, 'DECODE', 'Syntax\n------\n\nDECODE(crypt_str,pass_str)\n\nDescription\n-----------\n\nIn the default mode, DECODE decrypts the encrypted string <kbd>_crypt_str_</kbd> using <kbd>_pass_str_</kbd> as the password. _crypt_str_ should be a string returned from ENCODE(). The resulting string will be the original string only if <kbd>_pass_str_</kbd> is the same.\n\nIn Oracle mode, DECODE compares <kbd>_expr_</kbd> to the search expressions, in order. If it finds a match, the corresponding result expression is returned. If no matches are found, the default expression is returned, or NULL if no default is provided.\n\nNULL values are treated as equivalent.\n\nDECODE_ORACLE is a synonym for the Oracle-mode version of the function, and is available in all modes.\n\nExamples\n--------\n\nSELECT DECODE_ORACLE(2+1,31,''found1'',32,''found2'',''default'');\n+--------------------------------------------------------+\n| DECODE_ORACLE(2+1,31,''found1'',32,''found2'',''default'') |\n+--------------------------------------------------------+\n| found1                                                 |\n+--------------------------------------------------------+\n\nSELECT DECODE_ORACLE(2+4,31,''found1'',32,''found2'',''default'');\n+--------------------------------------------------------+\n| DECODE_ORACLE(2+4,31,''found1'',32,''found2'',''default'') |\n+--------------------------------------------------------+\n| found2                                                 |\n+--------------------------------------------------------+\n\nSELECT DECODE_ORACLE(2+2,31,''found1'',32,''found2'',''default'');\n+--------------------------------------------------------+\n| DECODE_ORACLE(2+2,31,''found1'',32,''found2'',''default'') |\n+--------------------------------------------------------+\n| default                                                |\n+--------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/decode', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/decode');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (281, 35, 'DES\\_DECRYPT', 'Syntax\n------\n\nDES_DECRYPT(crypt_str[,key_str])\n\nDescription\n-----------\n\nDecrypts a string encrypted with DES_ENCRYPT(). If an error occurs, this function returns NULL.\n\nThis function works only if MariaDB has been configured with TLS support.\n\nIf no key_str argument is given, DES_DECRYPT() examines the first byte of the encrypted string to determine the DES key number that was used to encrypt the original string, and then reads the key from the DES key file to decrypt the message. For this to work, the user must have the SUPER privilege. The key file can be specified with the--des-key-file server option.\n\nIf you pass this function a <kbd>key_str</kbd> argument, that string is used as the key for decrypting the message.\n\nIf the <kbd>crypt_str</kbd> argument does not appear to be an encrypted string, MariaDB returns the given <kbd>crypt_str</kbd>.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/des_decrypt', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/des_decrypt');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (282, 35, 'DES\\_ENCRYPT', 'Syntax\n------\n\nDES_ENCRYPT(str[,{key_num|key_str}])\n\nDescription\n-----------\n\nEncrypts the string with the given key using the Triple-DES algorithm.\n\nThis function works only if MariaDB has been configured with TLS support.\n\nThe encryption key to use is chosen based on the second argument toDES_ENCRYPT(), if one was given. With no argument, the first key from the DES key file is used. With a _key_num_ argument, the given key\\\nnumber (0-9) from the DES key file is used. With a _key_str_ argument, the given key string is used to encrypt _str_.\n\nThe key file can be specified with the --des-key-file server option.\n\nThe return string is a binary string where the first character isCHAR(128 | key_num). If an error occurs, DES_ENCRYPT() returns NULL.\n\nThe 128 is added to make it easier to recognize an encrypted key. If you use a string key, _key_num_ is 127.\n\nThe string length for the result is given by this formula:\n\n``sql\nnew_len = orig_len + (8 - (orig_len % 8)) + 1\n`\n\nEach line in the DES key file has the following format:\n\n`sql\nkey_num des_key_str\n`\n\nEach _key_num_ value must be a number in the range from 0 to 9. Lines in the file may be in any order. _des_key_str_ is the string that is used to encrypt the message. There should be at least one space between the number and the key. The first key is the default key that is used if you do not specify any key argument to DES_ENCRYPT().\n\nYou can tell MariaDB to read new key values from the key file with the FLUSH DES_KEY_FILE` statement. This requires the RELOAD privilege.\n\nOne benefit of having a set of default keys is that it gives applications a way to check for the existence of encrypted column values, without giving the end user the right to decrypt those values.\n\nExamples\n--------\n\nSELECT customer_address FROM customer_table \n   WHERE crypted_credit_card = DES_ENCRYPT(''credit_card_number'');\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/des_encrypt', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/des_encrypt');

INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (284, 35, 'ENCRYPT', 'Syntax\n------\n\nENCRYPT(str[,salt])\n\nDescription\n-----------\n\nEncrypts a string using the Unix crypt() system call, returning an encrypted binary string. The salt argument should be a string with at least two characters or the returned result will be NULL. If no salt argument is given, a random value of sufficient length is used.\n\nIt is not recommended to use ENCRYPT() with utf16, utf32 or ucs2 multi-byte character sets because the crypt() system call expects a string terminated with a zero byte.\n\nNote that the underlying crypt() system call may have some limitations, such as ignoring all but the first eight characters.\n\nIf the have_crypt system variable is set to NO (because the crypt() system call is not available), the ENCRYPT function will always return NULL.\n\nExamples\n--------\n\nSELECT ENCRYPT(''encrypt me'');\n+-----------------------+\n| ENCRYPT(''encrypt me'') |\n+-----------------------+\n| 4I5BsEx0lqTDk         |\n+-----------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/encrypt', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/encrypt');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (285, 35, 'KDF', 'Syntax\n------\n\nKDF(key_str, salt [, {info | iterations} [, kdf_name [, width ]]])\n\nDescription\n-----------\n\nKDF is a key derivation function, similar to OpenSSL''s EVP_KDF_derive(). The purpose of a KDF is to be slow, so if the calculated value is lost/stolen, the original key_str is not achievable easily with modern GPU. KDFs are therefore an ideal replacement for password hashes. KDFs can also pad out a password secret to the number of bits used in encryption algorithms.\n\nFor generating good encryption keys for AES_ENCRYPT a less expensive but cryptographically secure function like RANDOM_BYTES is recommended.\n\n <kbd>kdf_name</kbd> is "hkdf" or "pbkdf2_hmac" (default).\n Width (in bits) can be any number divisible by 8, by default it''s taken from @@block_encryption_mode.\n* Iterations must be positive, and is 1000 by default.\n\nNote that OpenSSL 1.0 doesn''t support HKDF, so in this case NULL is returned. This OpenSSL version is still used in SLES 12 and CentOS 7.\n\nExamples\n--------\n\nselect hex(kdf(''foo'', ''bar'', ''infa'', ''hkdf'')); \n+----------------------------------------+\n| hex(kdf(''foo'', ''bar'', ''infa'', ''hkdf'')) |\n+----------------------------------------+\n| 612875F859CFB4EE0DFEFF9F2A18E836       |\n+----------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/kdf', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/kdf');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (286, 35, 'MD5', 'Syntax\n------\n\nMD5(str)\n\nDescription\n-----------\n\nCalculates an MD5 128-bit checksum for the string.\n\nThe return value is a 32-hex digit string, and a nonbinary string in the connection character set and collation, determined by the values of the character_set_connection and collation_connection system variables.\n\nNULL is returned if the argument was NULL.\n\nDon''t use this function as an encryption function.\n\nMD5 can be used as a checksum to verify data integrity against unintentional corruption. Historically it was widely used as a cryptographic hash function; however it has been found to suffer from extensive vulnerabilities.\n\nSee https://en.wikipedia.org/wiki/MD5 for details.\n\nExamples\n--------\n\nSELECT MD5(''testing'');\n+----------------------------------+\n| MD5(''testing'')                   |\n+----------------------------------+\n| ae2b1fca515949e5d54fb22b8ed95575 |\n+----------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/md5', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/md5');


INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (289, 35, 'RANDOM\\_BYTES', 'Syntax\n------\n\nRANDOM_BYTES(length)\n\nDescription\n-----------\n\nGiven a _length_ from 1 to 1024, generates a binary string of _length_ consisting of random bytes generated by the SSL library''s random number generator.\n\nSee the RAND_bytes() function documentation of your SSL library for information on the random number generator. In the case of OpenSSL, a cryptographically secure pseudo random generator (CSPRNG) is used.\n\nStatements containing the RANDOM_BYTES function are unsafe for statement-based replication.\n\nAn error occurs if _length_ is outside the range 1 to 1024.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/random_bytes', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/random_bytes');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (290, 35, 'SHA1', 'Syntax\n------\n\nSHA1(str), SHA(str)\n\nDescription\n-----------\n\nCalculates an SHA-1 160-bit checksum for the string _str_, as described in RFC 3174 (Secure Hash Algorithm).\n\nThe value is returned as a string of 40 hex digits, or NULL if the argument was NULL. The return value is a nonbinary string in the connection character set and collation, determined by the values of the character_set_connection and collation_connection system variables.\n\nExamples\n--------\n\nSELECT SHA1(''some boring text'');\n+------------------------------------------+\n| SHA1(''some boring text'')                 |\n+------------------------------------------+\n| af969fc2085b1bb6d31e517d5c456def5cdd7093 |\n+------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/sha1', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/sha1');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (291, 35, 'SHA2', 'Syntax\n------\n\nSHA2(str,hash_len)\n\nDescription\n-----------\n\nGiven a string _str_, calculates an SHA-2 checksum, which is considered more cryptographically secure than its SHA-1 equivalent. The SHA-2 family includes SHA-224, SHA-256, SHA-384, and SHA-512, and the _hash_len_ must correspond to one of these, i.e. 224, 256, 384 or 512. 0 is equivalent to 256.\n\nThe return value is a nonbinary string in the connection character set and collation, determined by the values of the character_set_connection and collation_connection system variables.\n\nNULL is returned if the hash length is not valid, or the string str is NULL.\n\nSHA2 only works if MariaDB is configured with TLS support.\n\nExamples\n--------\n\nSELECT SHA2(''Maria'',224);\n+----------------------------------------------------------+\n| SHA2(''Maria'',224)                                        |\n+----------------------------------------------------------+\n| 6cc67add32286412efcab9d0e1675a43a5c2ef3cec8879f81516ff83 |\n+----------------------------------------------------------+\n\nSELECT SHA2(''Maria'',256);\n+------------------------------------------------------------------+\n| SHA2(''Maria'',256)                                                |\n+------------------------------------------------------------------+\n| 9ff18ebe7449349f358e3af0b57cf7a032c1c6b2272cb2656ff85eb112232f16 |\n+------------------------------------------------------------------+\n\nSELECT SHA2(''Maria'',0);\n+------------------------------------------------------------------+\n| SHA2(''Maria'',0)                                                  |\n+------------------------------------------------------------------+\n| 9ff18ebe7449349f358e3af0b57cf7a032c1c6b2272cb2656ff85eb112232f16 |\n+------------------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/sha2', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/sha2');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (292, 35, 'UNCOMPRESS', 'Syntax\n------\n\nUNCOMPRESS(string_to_uncompress)\n\nDescription\n-----------\n\nUncompresses a string compressed by the COMPRESS() function. If the argument is not a compressed value, the result is NULL. This function requires MariaDB to have been compiled with a compression library such as zlib. Otherwise, the return value is always NULL. The have_compress server system variable indicates whether a compression library is present.\n\nExamples\n--------\n\nSELECT UNCOMPRESS(COMPRESS(''a string''));\n+----------------------------------+\n| UNCOMPRESS(COMPRESS(''a string'')) |\n+----------------------------------+\n| a string                         |\n+----------------------------------+\n\nSELECT UNCOMPRESS(''a string'');\n+------------------------+\n| UNCOMPRESS(''a string'') |\n+------------------------+\n| NULL                   |\n+------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/uncompress', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/uncompress');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (293, 35, 'UNCOMPRESSED\\_LENGTH', 'Syntax\n------\n\nUNCOMPRESSED_LENGTH(compressed_string)\n\nDescription\n-----------\n\nReturns the length that the compressed string had before being compressed with COMPRESS().\n\nUNCOMPRESSED_LENGTH() returns NULL or an incorrect result if the string is not compressed.\n\nReturns MYSQL_TYPE_LONG, or int(10), if the result fits within 32-bits.\n\nExamples\n--------\n\nSELECT UNCOMPRESSED_LENGTH(COMPRESS(REPEAT(''a'',30)));\n+-----------------------------------------------+\n| UNCOMPRESSED_LENGTH(COMPRESS(REPEAT(''a'',30))) |\n+-----------------------------------------------+\n|                                            30 |\n+-----------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/uncompressed_length', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/uncompressed_length');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (294, 17, 'BENCHMARK', 'Syntax\n------\n\nBENCHMARK(count,expr)\n\nDescription\n-----------\n\nThe BENCHMARK() function executes the expression expr repeatedly count times. It may be used to time how quickly MariaDB processes the expression. The result value is always 0. The intended use is from within the mariadb client, which reports query execution times.\n\nExamples\n--------\n\nSELECT BENCHMARK(1000000,ENCODE(''hello'',''goodbye''));\n+----------------------------------------------+\n| BENCHMARK(1000000,ENCODE(''hello'',''goodbye'')) |\n+----------------------------------------------+\n|                                            0 |\n+----------------------------------------------+\n1 row in set (0.21 sec)\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/benchmark', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/benchmark');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (295, 17, 'BINLOG\\_GTID\\_POS', 'Syntax\n------\n\nBINLOG_GTID_POS(binlog_filename,binlog_offset)\n\nDescription\n-----------\n\nThe BINLOG_GTID_POS() function takes as input an old-style binary log position in the form of a file name and a file offset. It looks up the position in the current binlog, and returns a string representation of the corresponding GTID position. If the position is not found in the current binlog, NULL is returned.\n\nExamples\n--------\n\nSELECT BINLOG_GTID_POS("master-bin.000001", 600);\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/binlog_gtid_pos', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/binlog_gtid_pos');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (296, 17, 'CHARSET', 'Syntax\n------\n\nCHARSET(str)\n\nDescription\n-----------\n\nReturns the character set of the string argument. If str is not a string, it is considered as a binary string (so the function returns ''binary''). This applies to NULL, too. The return value is a string in the utf8 character set.\n\nExamples\n--------\n\nSELECT CHARSET(''abc'');\n+----------------+\n| CHARSET(''abc'') |\n+----------------+\n| latin1         |\n+----------------+\n\nSELECT CHARSET(CONVERT(''abc'' USING utf8));\n+------------------------------------+\n| CHARSET(CONVERT(''abc'' USING utf8)) |\n+------------------------------------+\n| utf8                               |\n+------------------------------------+\n\nSELECT CHARSET(USER());\n+-----------------+\n| CHARSET(USER()) |\n+-----------------+\n| utf8            |\n+-----------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/charset', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/charset');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (297, 17, 'COERCIBILITY', 'Syntax\n------\n\nCOERCIBILITY(str)\n\nDescription\n-----------\n\nReturns the collation coercibility value of the string argument. Coercibility defines what will be converted to what in case of collation conflict, with an expression with higher coercibility being converted to the collation of an expression with lower coercibility.\n\n| Coercibility | Description     | Example                                                     |\n| ------------ | --------------- | ----------------------------------------------------------- |\n| 0            | Explicit        | Value using a COLLATE clause                                |\n| 1            | No collation    | Concatenated strings using different collations             |\n| 2            | Implicit        | A string data type column value, CAST to a string data type |\n| 3            | System constant | DATABASE(), USER() return value                             |\n| 4            | Coercible       | Literal string                                              |\n| 5            | Numeric         | Numeric and temporal values                                 |\n| 6            | Ignorable       | NULL or derived from NULL                                   |\n\nExamples\n--------\n\nSELECT COERCIBILITY(_latin1 ''abc'' COLLATE latin1_swedish_ci);\n+-----------------------------------------------+\n| COERCIBILITY(_latin1 ''abc'' COLLATE latin1_swedish_ci) |\n+-----------------------------------------------+\n|                                             0 |\n+-----------------------------------------------+\n\nCREATE TABLE t (a VARCHAR(30) COLLATE uca1400_swedish_ai_ci, b VARCHAR(30) COLLATE uca1400_german2_ai_ci) CHARSET utf8mb4;\nINSERT INTO t VALUES (''abc'', ''def''); / a 2 coercibility /\nSELECT COERCIBILITY(CONCAT(a, b)) FROM t;\n+----------------------------+\n| COERCIBILITY(CONCAT(a, b)) |\n+----------------------------+\n|                          1 |\n+----------------------------+\n\nSELECT COERCIBILITY(CAST(1 AS CHAR));\n+-------------------------------+\n| COERCIBILITY(CAST(1 AS CHAR)) |\n+-------------------------------+\n|                             2 |\n+-------------------------------+\n\nSELECT COERCIBILITY(USER());\n+----------------------+\n| COERCIBILITY(USER()) |\n+----------------------+\n|                    3 |\n+----------------------+\n\nSELECT COERCIBILITY(''abc'');\n+---------------------+\n| COERCIBILITY(''abc'') |\n+---------------------+\n|                   4 |\n+---------------------+\n\nSELECT COERCIBILITY(1);\n+-----------------+\n| COERCIBILITY(1) |\n+-----------------+\n|               5 |\n+-----------------+\n\nSELECT COERCIBILITY(NULL);\n+--------------------+\n| COERCIBILITY(NULL) |\n+--------------------+\n|                  6 |\n+--------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/coercibility', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/coercibility');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (298, 17, 'COLLATION', 'Syntax\n------\n\nCOLLATION(str)\n\nDescription\n-----------\n\nReturns the collation of the string argument. If str is not a string, it is considered as a binary string (so the function returns ''binary''). This applies to NULL, too. The return value is a string in the utf8 character set.\n\nSee Character Sets and Collations.\n\nExamples\n--------\n\nSELECT COLLATION(''abc'');\n+-------------------+\n| COLLATION(''abc'')  |\n+-------------------+\n| latin1_swedish_ci |\n+-------------------+\n\nSELECT COLLATION(_utf8''abc'');\n+-----------------------+\n| COLLATION(_utf8''abc'') |\n+-----------------------+\n| utf8_general_ci       |\n+-----------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/collation', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/collation');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (299, 17, 'CONNECTION\\_ID', 'Syntax\n------\n\nCONNECTION_ID()\n\nDescription\n-----------\n\nReturns the connection ID for the connection. Every connection (including events) has an ID that is unique among the set of currently connected clients.\n\nReturns MYSQL_TYPE_LONG, or int(10).\n\nExamples\n--------\n\nSELECT CONNECTION_ID();\n+-----------------+\n| CONNECTION_ID() |\n+-----------------+\n|               3 |\n+-----------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/connection_id', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/connection_id');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (300, 17, 'CURRENT\\_ROLE', 'Syntax\n------\n\nCURRENT_ROLE, CURRENT_ROLE()\n\nDescription\n-----------\n\nReturns the current role name. The return value is a string in the\\\nutf8 character set.\n\nIf there is no current role, NULL is returned.\n\nUSER() returns the combination of user and host used to login. CURRENT_USER() returns the account used to determine current connection''s privileges.\n\nStatements using the CURRENT_ROLE function are not safe for statement-based replication.\n\nExamples\n--------\n\nSELECT CURRENT_ROLE;\n+--------------+\n| CURRENT_ROLE |\n+--------------+\n| NULL         |\n+--------------+\n\nSET ROLE staff;\n\nSELECT CURRENT_ROLE;\n+--------------+\n| CURRENT_ROLE |\n+--------------+\n| staff        |\n+--------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/current_role', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/current_role');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (301, 17, 'CURRENT\\_USER', 'Syntax\n------\n\nCURRENT_USER, CURRENT_USER()\n\nDescription\n-----------\n\nReturns the user name and host name combination for the MariaDB account that the server used to authenticate the current client. This account determines your access privileges. The return value is a string in the utf8 character set.\n\nThe value of CURRENT_USER() can differ from the value of USER(). CURRENT_ROLE() returns the current active role.\n\nStatements using the CURRENT_USER function are not safe for statement-based replication.\n\nExamples\n--------\n\nshell> mysql --user="anonymous"\n\nSELECT USER(),CURRENT_USER();\n+---------------------+----------------+\n| USER()              | CURRENT_USER() |\n+---------------------+----------------+\n| anonymous@localhost | @localhost     |\n+---------------------+----------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/current_user', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/current_user');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (302, 17, 'DATABASE', 'Syntax\n------\n\nDATABASE()\nSCHEMA()\n\nDescription\n-----------\n\nReturns the default (current) database name as a string in the utf8 character set. If there is no default database, DATABASE() returns NULL. Within a stored routine, the default database is the database that the routine is associated with, which is not necessarily the same as the database that is the default in the calling context.\n\nSCHEMA() is a synonym for DATABASE().\n\nTo select a default database, the USE statement can be run. Another way to set the default database is specifying its name at mariadb command line client startup.\n\nExamples\n--------\n\nSELECT DATABASE();\n+------------+\n| DATABASE() |\n+------------+\n| NULL       |\n+------------+\n\nUSE test;\nDatabase changed\n\nSELECT DATABASE();\n+------------+\n| DATABASE() |\n+------------+\n| test       |\n+------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/database', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/database');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (303, 17, 'DECODE\\_HISTOGRAM', 'Syntax\n------\n\nDECODE_HISTOGRAM(hist_type,histogram)\n\nDescription\n-----------\n\nReturns a string of comma separated numeric values corresponding to a probability distribution represented by the histogram of type hist_type (SINGLE_PREC_HB or DOUBLE_PREC_HB). The hist_type and histogram would be commonly used from the mysql.column_stats table.\n\nSee Histogram Based Statistics for details.\n\nExamples\n--------\n\nCREATE TABLE origin (\n  i INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,\n  v INT UNSIGNED NOT NULL\n);\n\nINSERT INTO origin(v) VALUES \n  (1),(2),(3),(4),(5),(10),(20),\n  (30),(40),(50),(60),(70),(80),\n  (90),(100),(200),(400),(800);\n\nSET histogram_size=10,histogram_type=SINGLE_PREC_HB;\n\nANALYZE TABLE origin PERSISTENT FOR ALL;\n+-------------+---------+----------+-----------------------------------------+\n| Table       | Op      | Msg_type | Msg_text                                |\n+-------------+---------+----------+-----------------------------------------+\n| test.origin | analyze | status   | Engine-independent statistics collected |\n| test.origin | analyze | status   | OK                                      |\n+-------------+---------+----------+-----------------------------------------+\n\nSELECT db_name,table_name,column_name,hist_type,\n  hex(histogram),decode_histogram(hist_type,histogram) \n  FROM mysql.column_stats WHERE db_name=''test'' and table_name=''origin'';\n+---------+------------+-------------+----------------+----------------------+-------------------------------------------------------------------+\n| db_name | table_name | column_name | hist_type      | hex(histogram)       | decode_histogram(hist_type,histogram)                             |\n+---------+------------+-------------+----------------+----------------------+-------------------------------------------------------------------+\n| test    | origin     | i           | SINGLE_PREC_HB | 0F2D3C5A7887A5C3D2F0 | 0.059,0.118,0.059,0.118,0.118,0.059,0.118,0.118,0.059,0.118,0.059 |\n| test    | origin     | v           | SINGLE_PREC_HB | 000001060C0F161C1F7F | 0.000,0.000,0.004,0.020,0.024,0.012,0.027,0.024,0.012,0.376,0.502 |\n+---------+------------+-------------+----------------+----------------------+-------------------------------------------------------------------+\n\nSET histogram_size=20,histogram_type=DOUBLE_PREC_HB;\n\nANALYZE TABLE origin PERSISTENT FOR ALL;\n+-------------+---------+----------+-----------------------------------------+\n| Table       | Op      | Msg_type | Msg_text                                |\n+-------------+---------+----------+-----------------------------------------+\n| test.origin | analyze | status   | Engine-independent statistics collected |\n| test.origin | analyze | status   | OK                                      |\n+-------------+---------+----------+-----------------------------------------+\n\nSELECT db_name,table_name,column_name,\n  hist_type,hex(histogram),decode_histogram(hist_type,histogram) \n  FROM mysql.column_stats WHERE db_name=''test'' and table_name=''origin'';\n+---------+------------+-------------+----------------+------------------------------------------+-----------------------------------------------------------------------------------------+\n| db_name | table_name | column_name | hist_type      | hex(histogram)                           | decode_histogram(hist_type,histogram)                                                   |\n+---------+------------+-------------+----------------+------------------------------------------+-----------------------------------------------------------------------------------------+\n| test    | origin     | i           | DOUBLE_PREC_HB | 0F0F2D2D3C3C5A5A78788787A5A5C3C3D2D2F0F0 | 0.05882,0.11765,0.05882,0.11765,0.11765,0.05882,0.11765,0.11765,0.05882,0.11765,0.05882 |\n| test    | origin     | v           | DOUBLE_PREC_HB | 5200F600480116067E0CB30F1B16831CB81FD67F | 0.00125,0.00250,0.00125,0.01877,0.02502,0.01253,0.02502,0.02502,0.01253,0.37546,0.50063 |\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/decode_histogram', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/decode_histogram');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (304, 17, 'DEFAULT', 'Syntax\n------\n\nDEFAULT(col_name)\n\nDescription\n-----------\n\nReturns the default value for a table column. If the column has no default value (and is not NULLABLE - NULLABLE fields have a NULL default), an error is returned.\n\nFor integer columns using AUTO_INCREMENT, 0 is returned.\n\nWhen using DEFAULT as a value to set in an INSERT or UPDATE statement, you can use the bare keyword DEFAULT without the parentheses and argument to refer to the column in context. You can only use DEFAULT as a bare keyword if you are using it alone without a surrounding expression or function.\n\nExamples\n--------\n\nSELECT i FROM t WHERE i != DEFAULT(i);\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/default', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/default');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (305, 17, 'FOUND\\_ROWS', 'Syntax\n------\n\nFOUND_ROWS()\n\nDescription\n-----------\n\nA SELECT statement may include a LIMIT clause to restrict the number of rows the server returns to the client. In some cases, it is desirable to know how many rows the statement would have returned without the LIMIT, but without running the statement again. To obtain this row count, include an SQL_CALC_FOUND_ROWS option in the SELECT statement, and then invoke FOUND_ROWS() afterwards.\n\nYou can also use FOUND_ROWS() to obtain the number of rows returned by a SELECT which does not contain a LIMIT clause. In this case you don''t need to use the SQL_CALC_FOUND_ROWS option. This can be useful for example in a stored procedure.\n\nAlso, this function works with some other statements which return a result set, including SHOW, DESC and HELP. For DELETE ... RETURNING you should use ROW_COUNT(). It also works as a prepared statement, or after executing a prepared statement.\n\nStatements which don''t return any results don''t affect FOUND_ROWS() - the previous value will still be returned.\n\nWarning: When used after a CALL statement, this function returns the number of rows selected by the last query in the procedure, not by the whole procedure.\n\nStatements using the FOUND_ROWS() function are not safe for statement-based replication.\n\nExamples\n--------\n\nSHOW ENGINES\\G\n************************ 1. row *********************\n      Engine: CSV\n     Support: YES\n     Comment: Stores tables as CSV files\nTransactions: NO\n          XA: NO\n  Savepoints: NO\n********************* 2. row *********************\n      Engine: MRG_MyISAM\n     Support: YES\n     Comment: Collection of identical MyISAM tables\nTransactions: NO\n          XA: NO\n  Savepoints: NO\n\n...\n\n********************* 8. row ************************\n      Engine: PERFORMANCE_SCHEMA\n     Support: YES\n     Comment: Performance Schema\nTransactions: NO\n          XA: NO\n  Savepoints: NO\n8 rows in set (0.000 sec)\n\nSELECT FOUND_ROWS();\n+--------------+\n| FOUND_ROWS() |\n+--------------+\n|           8 |\n+--------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/found_rows', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/found_rows');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (306, 17, 'LAST\\_INSERT\\_ID', 'Syntax\n------\n\nLAST_INSERT_ID(), LAST_INSERT_ID(expr)\n\nDescription\n-----------\n\nLAST_INSERT_ID() (no arguments) returns the first automatically generated value successfully inserted for an AUTO_INCREMENT column as a result of the most recently executed INSERT\\\nstatement. The value of LAST_INSERT_ID() remains unchanged if no rows are successfully inserted.\n\nIf one gives an argument to LAST_INSERT_ID(), then it will return the value of the expression and\\\nthe next call to LAST_INSERT_ID() will return the same value. The value is also sent to the client\\\nand can be accessed by the mysql_insert_id function.\n\nFor example, after inserting a row that generates an AUTO_INCREMENT value, you can get the value like this:\n\n``sql\nSELECT LAST_INSERT_ID();\n+------------------+\n| LAST_INSERT_ID() |\n+------------------+\n|                9 |\n+------------------+\n`\n\nYou can also use LAST_INSERT_ID() to delete the last inserted row:\n\n`sql\nDELETE FROM product WHERE id = LAST_INSERT_ID();\n`\n\nIf no rows were successfully inserted, LAST_INSERT_ID() returns 0.\n\nYou can also use INSERT...RETURNING for this purpose.\n\nThe value of LAST_INSERT_ID() will be consistent across all versions if all rows in the INSERT or UPDATE statement were successful.\n\nThe currently executing statement does not affect the value of LAST_INSERT_ID(). Suppose that you generate an AUTO_INCREMENT value with one statement, and then refer to LAST_INSERT_ID() in a\\\nmultiple-row INSERT statement that inserts rows into a table with its own AUTO_INCREMENT column. The value of LAST_INSERT_ID() will remain stable in the second statement; its value for the second and later rows is not affected by the earlier row insertions. (However, if you mix references to LAST_INSERT_ID() and LAST_INSERT_ID(<kbd>expr</kbd>), the effect is undefined.)\n\nIf the previous statement returned an error, the value of LAST_INSERT_ID() is undefined. For transactional tables, if the statement is rolled back due to an error, the value of LAST_INSERT_ID() is left undefined. For manual ROLLBACK, the value of LAST_INSERT_ID() is not restored to that before the transaction; it remains as it was at the point of the ROLLBACK.\n\nWithin the body of a stored routine (procedure or function) or a trigger, the value of LAST_INSERT_ID() changes the same way as for statements executed outside the body of these kinds of objects. The\\\neffect of a stored routine or trigger upon the value of LAST_INSERT_ID() that is seen by following statements depends on the kind of routine:\n\n If a stored procedure executes statements that change the value of LAST_INSERT_ID()`, the new value will be seen by statements that follow the procedure call.\n For stored functions and triggers that change the value, the value is restored when the function or trigger ends, so following statements will not see a changed value.\n\nExamples\n--------\n\nCREATE TABLE t (\n  id INTEGER UNSIGNED AUTO_INCREMENT PRIMARY KEY, \n  f VARCHAR(1)) \nENGINE = InnoDB;\n\nINSERT INTO t(f) VALUES(''a'');\n\nSELECT LAST_INSERT_ID();\n+------------------+\n| LAST_INSERT_ID() |\n+------------------+\n|                1 |\n+------------------+\n\nINSERT INTO t(f) VALUES(''b'');\n\nINSERT INTO t(f) VALUES(''c'');\n\nSELECT LAST_INSERT_ID();\n+------------------+\n| LAST_INSERT_ID() |\n+------------------+\n|                3 |\n+------------------+\n\nINSERT INTO t(f) VALUES(''d''),(''e'');\n\nSELECT LAST_INSERT_ID();\n+------------------+\n| LAST_INSERT_ID() |\n+------------------+\n|                4 |\n+------------------+\n\nSELECT  FROM t;\n+----+------+\n| id | f    |\n+----+------+\n|  1 | a    |\n|  2 | b    |\n|  3 | c    |\n|  4 | d    |\n|  5 | e    |\n+----+------+\n\nSELECT LAST_INSERT_ID(12);\n+--------------------+\n| LAST_INSERT_ID(12) |\n+--------------------+\n|                 12 |\n+--------------------+\n\nSELECT LAST_INSERT_ID();\n+------------------+\n| LAST_INSERT_ID() |\n+------------------+\n|               12 |\n+------------------+\n\nINSERT INTO t(f) VALUES(''f'');\n\nSELECT LAST_INSERT_ID();\n+------------------+\n| LAST_INSERT_ID() |\n+------------------+\n|                6 |\n+------------------+\n\nSELECT  FROM t;\n+----+------+\n| id | f    |\n+----+------+\n|  1 | a    |\n|  2 | b    |\n|  3 | c    |\n|  4 | d    |\n|  5 | e    |\n|  6 | f    |\n+----+------+\n\nSELECT LAST_INSERT_ID(12);\n+--------------------+\n| LAST_INSERT_ID(12) |\n+--------------------+\n|                 12 |\n+--------------------+\n\nINSERT INTO t(f) VALUES(''g'');\n\nSELECT * FROM t;\n+----+------+\n| id | f    |\n+----+------+\n|  1 | a    |\n|  2 | b    |\n|  3 | c    |\n|  4 | d    |\n|  5 | e    |\n|  6 | f    |\n|  7 | g    |\n+----+------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/last_insert_id', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/last_insert_id');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (307, 17, 'LAST\\_VALUE', 'Syntax\n------\n\nLAST_VALUE(expr,[expr,...])\n\nDescription\n-----------\n\nLAST_VALUE() evaluates all expressions and returns the last. This is useful together with setting user variables to a value with @var:=expr, for example when you want to get data of rows updated/deleted without having to do two queries against the table.\n\nLAST_VALUE can be used as a window function.\n\nReturns NULL if no last value exists.\n\nExamples\n--------\n\nCREATE TABLE t1 (a int, b int);\nINSERT INTO t1 VALUES(1,10),(2,20);\nDELETE FROM t1 WHERE a=1 AND last_value(@a:=a,@b:=b,1);\nSELECT @a,@b;\n+------+------+\n| @a   | @b   |\n+------+------+\n|    1 |   10 |\n+------+------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/last_value', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/last_value');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (308, 17, 'PROCEDURE ANALYSE', 'Syntax\n------\n\nANALYSE([max_elements[,max_memory]])\n\nDescription\n-----------\n\nThis procedure is defined in the sql/sql_analyse.cc file. It examines the result from a query and returns an analysis of the results that suggests optimal data types for each column. To obtain this analysis, append PROCEDURE ANALYSE to the end of a SELECT statement:\n\n``sql\nSELECT ... FROM ... WHERE ... PROCEDURE ANALYSE([max_elements,[max_memory]])\n`\n\nFor example:\n\n`sql\nSELECT col1, col2 FROM table1 PROCEDURE ANALYSE(10, 2000);\n`\n\nThe results show some statistics for the values returned by the query, and propose an optimal data type for the columns. This can be helpful for checking your existing tables, or after importing new data. You may need to try different settings for the arguments so that PROCEDURE ANALYSE() does not suggest the ENUM data type when it is not appropriate.\n\nThe arguments are optional and are used as follows:\n\n max_elements (default 256) is the maximum number of distinct values that analyse notices per column. This is used by analyse to check whether the optimal data type should be of type ENUM; if there are more than max_elements distinct values, then ENUM` is not a suggested type.\n max_memory (default 8192) is the maximum amount of memory that analyse should allocate per column while trying to find all distinct values.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/procedure-analyse', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/procedure-analyse');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (309, 17, 'ROW\\_COUNT', 'Syntax\n------\n\nROW_COUNT()\n\nDescription\n-----------\n\nROW_COUNT() returns the number of rows updated, inserted or deleted by the preceding statement. This is the same as the row count that the mariadb client displays and the value from the mysql_affected_rows() C API function.\n\nGenerally:\n\n For statements which return a result set (such as SELECT, SHOW, DESC or HELP), returns -1, even when the result set is empty. This is also true for administrative statements, such as OPTIMIZE.\n For DML statements other than SELECT and for ALTER TABLE, returns the number of affected rows.\n For DDL statements (including TRUNCATE) and for other statements which don''t return any result set (such as USE, DO, SIGNAL or DEALLOCATE PREPARE), returns 0.\n\nFor UPDATE, affected rows is by default the number of rows that were actually changed. If the CLIENT_FOUND_ROWS flag to mysql_real_connect() is specified when connecting to mariadbd, affected rows is instead the number of rows matched by the WHERE clause.\n\nFor REPLACE, deleted rows are also counted. So, if REPLACE deletes a row and adds a new row, ROW_COUNT() returns 2.\n\nFor INSERT ... ON DUPLICATE KEY, values returned are as follows:\n\n 0: an existing row is set to its current values, and the CLIENT_FOUND_ROWS is not set.\n 1: the values are inserted as a new row, or an existing row is set to its current values, and the CLIENT_FOUND_ROWS is set.\n 2: an existing row is updated with new values.\n\nROW_COUNT() does not take into account rows that are not directly deleted/updated by the last statement. This means that rows deleted by foreign keys or triggers are not counted.\n\nWarning: You can use ROW_COUNT() with prepared statements, but you need to call it after EXECUTE, not after DEALLOCATE PREPARE, because the row count for allocate prepare is always 0.\n\nWarning: When used after a CALL statement, this function returns the number of rows affected by the last statement in the procedure, not by the whole procedure.\n\nWarning: After INSERT DELAYED, ROW_COUNT() returns the number of the rows you tried to insert, not the number of the successful writes.\n\nThis information can also be found in the diagnostics area.\n\nStatements using the ROW_COUNT() function are not safe for statement-based replication.\n\nExamples\n--------\n\nCREATE TABLE t (A INT);\n\nINSERT INTO t VALUES(1),(2),(3);\n\nSELECT ROW_COUNT();\n+-------------+\n| ROW_COUNT() |\n+-------------+\n|           3 |\n+-------------+\n\nDELETE FROM t WHERE A IN(1,2);\n\nSELECT ROW_COUNT(); \n+-------------+\n| ROW_COUNT() |\n+-------------+\n|           2 |\n+-------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/row_count', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/row_count');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (310, 17, 'ROWNUM', 'Syntax\n------\n\nROWNUM()\n\nDescription\n-----------\n\nROWNUM() returns the current number of accepted rows in the current context. It main purpose is to emulate the ROWNUM pseudo column in Oracle. For MariaDB native applications, we recommend the usage of LIMIT, as it is easier to use and gives more predictable results than the usage of ROWNUM().\n\nThe main difference between using LIMIT andROWNUM() to limit the rows in the result is thatLIMIT works on the result set while ROWNUM works on the number of accepted rows (before any ORDER orGROUP BY clauses).\n\nThe following queries will return the same results:\n\n``sql\nSELECT  FROM t1 LIMIT 10;\nSELECT  FROM t1 WHERE ROWNUM() <= 10;\n`\n\nWhile the following may return different results based on in which orders the rows are found:\n\n`sql\nSELECT  FROM t1 ORDER BY a LIMIT 10;\nSELECT  FROM t1 ORDER BY a WHERE ROWNUM() <= 10;\n`\n\nThe recommended way to use ROWNUM to limit the number of returned rows and get predictable results is to have the query in a subquery and test for ROWNUM() in the outer query:\n\n`sql\nSELECT  FROM (SELECT  FROM t1 ORDER BY a) WHERE ROWNUM() <= 10;\n`\n\nROWNUM() can be used in the following contexts:\n\n SELECT\n INSERT\n UPDATE\n DELETE\n* LOAD DATA INFILE\n\nUsed in other contexts, ROWNUM()` will return 0.\n\nExamples\n--------\n\nINSERT INTO t1 VALUES (1,ROWNUM()),(2,ROWNUM()),(3,ROWNUM());\n\nINSERT INTO t1 VALUES (1),(2) RETURNING a, ROWNUM();\n\nUPDATE t1 SET row_num_column=ROWNUM();\n\nDELETE FROM t1 WHERE a < 10 AND ROWNUM() < 2;\n\nLOAD DATA INFILE ''filename'' INTO TABLE t1 fields terminated BY '','' \n  lines terminated BY "\\r\\n" (a,b) SET c=ROWNUM();\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/rownum', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/rownum');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (311, 17, 'SCHEMA', 'Syntax\n------\n\nSCHEMA()\n\nDescription\n-----------\n\nThis function is a synonym for DATABASE().\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/schema', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/schema');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (312, 17, 'SESSION\\_USER', 'Syntax\n------\n\nSESSION_USER()\n\nDescription\n-----------\n\nShows the value of CURRENT_USER() when the session was created, that is, it shows a user@host pair from the mysql.global_priv table, like CURRENT_USER(), but unlike CURRENT_USER() it will not change inside stored routines and views. This is SQL Standard behavior for the SESSION_USER function.\n\nSESSION_USER() is a synonym for USER().\n\nBackward-compatible behavior can be restored by setting old mode to SESSION_USER_IS_USER.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/session_user', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/session_user');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (313, 17, 'SYSTEM\\_USER', 'Syntax\n------\n\nSYSTEM_USER()\n\nDescription\n-----------\n\nSYSTEM_USER() is a synonym for USER().\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/system_user', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/system_user');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (314, 17, 'USER', 'Syntax\n------\n\nUSER()\n\nDescription\n-----------\n\nReturns the current MariaDB user name and host name, given when authenticating to MariaDB, as a string in the utf8 character set.\n\nThe value of USER() may differ from the value of CURRENT_USER(), which is the user used to authenticate the current client. CURRENT_ROLE() returns the currently active role.\n\nSYSTEM_USER() is a synonym for USER().\n\nSYSTEM_USER() and SESSION_USER are synonyms for USER().\n\nStatements using the USER() function or one of its synonyms are not safe for statement level replication.\n\nExamples\n--------\n\nshell> mysql --user="anonymous"\n\nSELECT USER(),CURRENT_USER();\n+---------------------+----------------+\n| USER()              | CURRENT_USER() |\n+---------------------+----------------+\n| anonymous@localhost | @localhost     |\n+---------------------+----------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/user', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/user');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (315, 17, 'VERSION', 'Syntax\n------\n\nVERSION()\n\nDescription\n-----------\n\nReturns a string that indicates the MariaDB server version. The string uses the utf8 character set.\n\nExamples\n--------\n\nSELECT VERSION();\n+----------------+\n| VERSION()      |\n+----------------+\n| 10.4.7-MariaDB |\n+----------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/version', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/version');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (316, 14, 'GET\\_LOCK', 'Syntax\n------\n\nGET_LOCK(str,timeout)\n\nDescription\n-----------\n\nTries to obtain a lock with a name given by the string str, using a timeout of timeout seconds. Returns 1 if the lock was obtained successfully, 0 if the attempt timed out (for example, because another client has previously locked the name), or NULL if an error occurred (such as running out of memory or the thread was killed with mariadb-admin kill).\n\nA lock is released with RELEASE_LOCK(), when the connection terminates (either normally or abnormally). A connection can hold multiple locks at the same time, so a lock that is no longer needed needs to be explicitly released.\n\nThe IS_FREE_LOCK function returns whether a specified lock is free or not, and the IS_USED_LOCK whether the function is in use or not.\n\nLocks obtained with GET_LOCK() do not interact with transactions. That is, committing a transaction does not release any such locks obtained during the transaction.\n\nIt is also possible to recursively set the same lock. If a lock with the same name is set n times, it needs to be released n times as well.\n\nstr is case insensitive for GET_LOCK() and related functions. If str is an empty string or NULL, GET_LOCK() returns NULL and does nothing. timeout supports microseconds.\n\nIf the metadata_lock_info plugin is installed, locks acquired with this function are visible in the Information Schema METADATA_LOCK_INFO table.\n\nThis function can be used to implement application locks or to simulate record locks. Names are locked on a server-wide basis. If a name has been locked by one client, GET_LOCK() blocks any request by another client for a lock with the same name. This allows clients that agree on a given lock name to use the name to perform cooperative advisory locking. But be aware that it also allows a client that is not among the set of cooperating clients to lock a name, either inadvertently or deliberately, and thus prevent any of the cooperating clients from locking that name. One way to reduce the likelihood of this is to use lock names that are database-specific or application-specific. For example, use lock names of the form db_name.str or app_name.str.\n\nStatements using the GET_LOCK function are not safe for statement-based replication.\n\nThe patch to permit multiple locks was contributed by Konstantin "Kostja" Osipov (MDEV-3917).\n\nExamples\n--------\n\nSELECT GET_LOCK(''lock1'',10);\n+----------------------+\n| GET_LOCK(''lock1'',10) |\n+----------------------+\n|                    1 |\n+----------------------+\n\nSELECT IS_FREE_LOCK(''lock1''), IS_USED_LOCK(''lock1'');\n+-----------------------+-----------------------+\n| IS_FREE_LOCK(''lock1'') | IS_USED_LOCK(''lock1'') |\n+-----------------------+-----------------------+\n|                     0 |                    46 |\n+-----------------------+-----------------------+\n\nSELECT IS_FREE_LOCK(''lock2''), IS_USED_LOCK(''lock2'');\n+-----------------------+-----------------------+\n| IS_FREE_LOCK(''lock2'') | IS_USED_LOCK(''lock2'') |\n+-----------------------+-----------------------+\n|                     1 |                  NULL |\n+-----------------------+-----------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/get_lock', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/get_lock');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (317, 14, 'INET6\\_ATON', 'Syntax\n------\n\nINET6_ATON(expr)\n\nDescription\n-----------\n\nGiven an IPv6 or IPv4 network address as a string, returns a binary string that represents the numeric value of the address.\n\nNo trailing zone ID''s or traling network masks are permitted. For IPv4 addresses, or IPv6 addresses with IPv4 address parts, no classful addresses or trailing port numbers are permitted and octal numbers are not supported.\n\nThe returned binary string will be VARBINARY(16) or VARBINARY(4) for IPv6 and IPv4 addresses respectively.\n\nReturns NULL if the argument is not understood.\n\nMariaDB starting with 10.5.0\n\nINET6_ATON can take INET6 as an argument.\n\nINET6_ATON cannot take INET6 as an argument.\n\nExamples\n--------\n\nSELECT HEX(INET6_ATON(''10.0.1.1''));\n+-----------------------------+\n| HEX(INET6_ATON(''10.0.1.1'')) |\n+-----------------------------+\n| 0A000101                    |\n+-----------------------------+\n\nSELECT HEX(INET6_ATON(''48f3::d432:1431:ba23:846f''));\n+----------------------------------------------+\n| HEX(INET6_ATON(''48f3::d432:1431:ba23:846f'')) |\n+----------------------------------------------+\n| 48F3000000000000D4321431BA23846F             |\n+----------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/inet6_aton', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/inet6_aton');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (318, 14, 'INET6\\_NTOA', 'Syntax\n------\n\nINET6_NTOA(expr)\n\nDescription\n-----------\n\nGiven an IPv6 or IPv4 network address as a numeric binary string, returns the address as a nonbinary string in the connection character set.\n\nThe return string is lowercase, and is platform independent, since it does not use functions specific to the operating system. It has a maximum length of 39 characters.\n\nReturns NULL if the argument is not understood.\n\nExamples\n--------\n\nSELECT INET6_NTOA(UNHEX(''0A000101''));\n+-------------------------------+\n| INET6_NTOA(UNHEX(''0A000101'')) |\n+-------------------------------+\n| 10.0.1.1                      |\n+-------------------------------+\n\nSELECT INET6_NTOA(UNHEX(''48F3000000000000D4321431BA23846F''));\n+-------------------------------------------------------+\n| INET6_NTOA(UNHEX(''48F3000000000000D4321431BA23846F'')) |\n+-------------------------------------------------------+\n| 48f3::d432:1431:ba23:846f                             |\n+-------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/inet6_ntoa', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/inet6_ntoa');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (319, 14, 'INET\\_ATON', 'Syntax\n------\n\nINET_ATON(expr)\n\nDescription\n-----------\n\nGiven the dotted-quad representation of an IPv4 network address as a string, returns an integer that represents the numeric value of the address. Addresses may be 4- or 8-byte addresses.\n\nReturns NULL if the argument is not understood.\n\nExamples\n--------\n\nSELECT INET_ATON(''192.168.1.1'');\n+--------------------------+\n| INET_ATON(''192.168.1.1'') |\n+--------------------------+\n|               3232235777 |\n+--------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/inet_aton', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/inet_aton');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (320, 14, 'INET\\_NTOA', 'Syntax\n------\n\nINET_NTOA(expr)\n\nDescription\n-----------\n\nGiven a numeric IPv4 network address in network byte order (4 or 8 byte), returns the dotted-quad representation of the address as a string.\n\nExamples\n--------\n\nSELECT INET_NTOA(3232235777);\n+-----------------------+\n| INET_NTOA(3232235777) |\n+-----------------------+\n| 192.168.1.1           |\n+-----------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/inet_ntoa', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/inet_ntoa');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (321, 14, 'IS\\_FREE\\_LOCK', 'Syntax\n------\n\nIS_FREE_LOCK(str)\n\nDescription\n-----------\n\nChecks whether the lock named str is free to use (that is, not locked). Returns 1 if the lock is free (no one is using the lock),0 if the lock is in use, and NULL if an error occurs (such as an incorrect argument, like an empty string or NULL). str is case insensitive.\n\nIf the metadata_lock_info plugin is installed, the Information Schema metadata_lock_info table contains information about locks of this kind (as well as metadata locks).\n\nStatements using the IS_FREE_LOCK function are not safe for statement-based replication.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/is_free_lock', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/is_free_lock');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (322, 14, 'IS\\_IPV4', 'Syntax\n------\n\nIS_IPV4(expr)\n\nDescription\n-----------\n\nIf the expression is a valid IPv4 address, returns 1, otherwise returns 0.\n\nIS_IPV4() is stricter than INET_ATON(), but as strict as INET6_ATON(), in determining the validity of an IPv4 address. This implies that if IS_IPV4 returns 1, the same expression will always return a non-NULL result when passed to INET_ATON(), but that the reverse may not apply.\n\nExamples\n--------\n\nSELECT IS_IPV4(''1110.0.1.1'');\n+-----------------------+\n| IS_IPV4(''1110.0.1.1'') |\n+-----------------------+\n|                     0 |\n+-----------------------+\n\nSELECT IS_IPV4(''48f3::d432:1431:ba23:846f'');\n+--------------------------------------+\n| IS_IPV4(''48f3::d432:1431:ba23:846f'') |\n+--------------------------------------+\n|                                    0 |\n+--------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/is_ipv4', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/is_ipv4');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (323, 14, 'IS\\_IPV4\\_COMPAT', 'Syntax\n------\n\nIS_IPV4_COMPAT(expr)\n\nDescription\n-----------\n\nReturns 1 if a given numeric binary string IPv6 address, such as returned by INET6_ATON(), is IPv4-compatible, otherwise returns 0.\n\nWhen the argument is not INET6, automatic implicit CAST to INET6 is applied. As a consequence, IS_IPV4_COMPAT now understands arguments in both text representation and binary(16) representation.\n\nThe function understands only binary(16) representation.\n\nExamples\n--------\n\nSELECT IS_IPV4_COMPAT(INET6_ATON(''::10.0.1.1''));\n+------------------------------------------+\n| IS_IPV4_COMPAT(INET6_ATON(''::10.0.1.1'')) |\n+------------------------------------------+\n|                                        1 |\n+------------------------------------------+\n\nSELECT IS_IPV4_COMPAT(INET6_ATON(''::48f3::d432:1431:ba23:846f''));\n+-----------------------------------------------------------+\n| IS_IPV4_COMPAT(INET6_ATON(''::48f3::d432:1431:ba23:846f'')) |\n+-----------------------------------------------------------+\n|                                                         0 |\n+-----------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/is_ipv4_compat', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/is_ipv4_compat');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (324, 14, 'IS\\_IPV4\\_MAPPED', 'Syntax\n------\n\nIS_IPV4_MAPPED(expr)\n\nDescription\n-----------\n\nReturns 1 if a given a numeric binary string IPv6 address, such as returned by INET6_ATON(), is a valid IPv4-mapped address, otherwise returns 0.\n\nWhen the argument is not INET6, automatic implicit CAST to INET6 is applied. As a consequence, IS_IPV4_MAPPED now understands arguments in both text representation and binary(16) representation.\n\nThe function understands only binary(16) representation.\n\nExamples\n--------\n\nSELECT IS_IPV4_MAPPED(INET6_ATON(''::10.0.1.1''));\n+------------------------------------------+\n| IS_IPV4_MAPPED(INET6_ATON(''::10.0.1.1'')) |\n+------------------------------------------+\n|                                        0 |\n+------------------------------------------+\n\nSELECT IS_IPV4_MAPPED(INET6_ATON(''::ffff:10.0.1.1''));\n+-----------------------------------------------+\n| IS_IPV4_MAPPED(INET6_ATON(''::ffff:10.0.1.1'')) |\n+-----------------------------------------------+\n|                                             1 |\n+-----------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/is_ipv4_mapped', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/is_ipv4_mapped');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (325, 14, 'IS\\_IPV6', 'Syntax\n------\n\nIS_IPV6(expr)\n\nDescription\n-----------\n\nReturns 1 if the expression is a valid IPv6 address specified as a string, otherwise returns 0. Does not consider IPv4 addresses to be valid IPv6 addresses.\n\nExamples\n--------\n\nSELECT IS_IPV6(''48f3::d432:1431:ba23:846f'');\n+--------------------------------------+\n| IS_IPV6(''48f3::d432:1431:ba23:846f'') |\n+--------------------------------------+\n|                                    1 |\n+--------------------------------------+\n1 row in set (0.02 sec)\n\nSELECT IS_IPV6(''10.0.1.1'');\n+---------------------+\n| IS_IPV6(''10.0.1.1'') |\n+---------------------+\n|                   0 |\n+---------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/is_ipv6', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/is_ipv6');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (326, 14, 'IS\\_USED\\_LOCK', 'Syntax\n------\n\nIS_USED_LOCK(str)\n\nDescription\n-----------\n\nChecks whether the lock named str is in use (that is, locked). If so, it returns the connection identifier of the client that holds the lock. Otherwise, it returns NULL. str is case insensitive.\n\nIf the metadata_lock_info plugin is installed, the Information Schema metadata_lock_info table contains information about locks of this kind (as well as metadata locks).\n\nStatements using the IS_USED_LOCK function are not safe for statement-based replication.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/is_used_lock', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/is_used_lock');

INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (328, 14, 'MASTER\\_POS\\_WAIT', 'Syntax\n------\n\nMASTER_POS_WAIT(log_name,log_pos[,timeout,["connection_name"]])\n\nDescription\n-----------\n\nThis function is useful in replication for controlling master/slave synchronization. It blocks until the slave has read and applied all updates up to the specified position (log_name,log_pos) in the binary log. The return value is the number of log events the slave had to wait for to advance to the specified position. The function returns NULL if the slave SQL thread is not started, the slave''s master information is not initialized, the arguments are incorrect, or an error occurs. It returns -1 if\\\nthe timeout has been exceeded. If the slave SQL thread stops whileMASTER_POS_WAIT() is waiting, the function returns NULL. If the slave is past the specified position, the function returns immediately.\n\nIf a timeout value is specified, MASTER_POS_WAIT() stops waiting when timeout seconds have elapsed. timeout must be greater than 0; a zero or negative timeout means no timeout.\n\nThe connection_name is used when you are using multi-source-replication. If you don''t specify it, it''s set to the value of the default_master_connection system variable.\n\nStatements using the MASTER_POS_WAIT() function are not safe for statement-based replication.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/master_pos_wait', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/master_pos_wait');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (329, 14, 'FORMAT\\_BYTES', 'Syntax\n------\n\nFORMAT_BYTES(double)\n\nDescription\n-----------\n\nGiven a byte count, returns a string consisting of a value and the units in a human-readable format. The units will be in bytes, KiB (kibibytes), MiB (mebibytes), GiB (gibibytes), TiB (tebibytes), PiB (pebibytes) or EiB (exbibytes).\n\nThe binary prefixes (kibi, mebi, gibi, tebi, pebi and exbi) were created in December 1998 by the International Electrotechnical Commission to avoid possible ambiguity, as the widely-used prefixes kilo, mega, giga, tera, peta and exa can be used to refer to both the power-of-10 decimal system multipliers and the power-of-two binary system multipliers.\n\nThis function is similar to the Sys Schema format_bytes function, except that function does not display exbibytes.\n\nExamples\n--------\n\nSELECT FORMAT_BYTES(1000)FORMAT_BYTES(1024);\n+--------------------+--------------------+\n| FORMAT_BYTES(1000) | FORMAT_BYTES(1024) |\n+--------------------+--------------------+\n| 1000 bytes         | 1.00 KiB           |\n+--------------------+--------------------+\n\nSELECT FORMAT_BYTES(1000000),FORMAT_BYTES(1048576);\n+-----------------------+-----------------------+\n| FORMAT_BYTES(1000000) | FORMAT_BYTES(1048576) |\n+-----------------------+-----------------------+\n| 976.56 KiB            | 1.00 MiB              |\n+-----------------------+-----------------------+\n\nSELECT FORMAT_BYTES(1000000000),FORMAT_BYTES(1073741874);\n+--------------------------+--------------------------+\n| FORMAT_BYTES(1000000000) | FORMAT_BYTES(1073741874) |\n+--------------------------+--------------------------+\n| 953.67 MiB               | 1.00 GiB                     |\n+--------------------------+--------------------------+\n\nSELECT FORMAT_BYTES(1000000000000),FORMAT_BYTES(1099511627776);\n+-----------------------------+-----------------------------+\n| FORMAT_BYTES(1000000000000) | FORMAT_BYTES(1099511627776) |\n+-----------------------------+-----------------------------+\n| 931.32 GiB                  | 1.00 TiB                    |\n+-----------------------------+-----------------------------+\n\nSELECT FORMAT_BYTES(1000000000000000),FORMAT_BYTES(1125899906842624);\n+--------------------------------+--------------------------------+\n| FORMAT_BYTES(1000000000000000) | FORMAT_BYTES(1125899906842624) |\n+--------------------------------+--------------------------------+\n| 909.49 TiB                     | 1.00 PiB                       |\n+--------------------------------+--------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/miscellaneous-functions-format_bytes', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/miscellaneous-functions-format_bytes');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (330, 14, 'NAME\\_CONST', 'Syntax\n------\n\nNAME_CONST(name,value)\n\nDescription\n-----------\n\nReturns the given value. When used to produce a result set column,NAME_CONST() causes the column to have the given name. The arguments should be constants.\n\nThis function is used internally when replicating stored procedures. It makes little sense to use it explicitly in SQL statements, and it was not supposed to be used like that.\n\n``sql\nSELECT NAME_CONST(''myname'', 14);\n+--------+\n| myname |\n+--------+\n|     14 |\n+--------+\n``\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/name_const', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/name_const');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (331, 14, 'OLD\\_VALUE', 'Syntax\n------\n\nOLD_VALUE(val)\n\nDescription\n-----------\n\nIn the RETURNING clause of an UPDATE statement, OLD_VALUE() returns the value before the update. The function is meaningful only in this context.\n\nExamples\n--------\n\nUPDATE t SET a=a+1 RETURNING OLD_VALUE(a) AS old, a as new;\n+------+------+\n| old  | new  |\n+------+------+\n|    1 |    2 |\n+------+------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/old-value', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/old-value');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (332, 14, 'RELEASE\\_ALL\\_LOCKS', 'Syntax\n------\n\nRELEASE_ALL_LOCKS()\n\nDescription\n-----------\n\nReleases all named locks held by the current session. Returns the number of locks released, or 0 if none were held.\n\nStatements using the RELEASE_ALL_LOCKS function are not safe for statement-based replication.\n\nExamples\n--------\n\nSELECT RELEASE_ALL_LOCKS();\n+---------------------+\n| RELEASE_ALL_LOCKS() | \n+---------------------+\n|                   0 |\n+---------------------+\n\nSELECT GET_LOCK(''lock1'',10);\n+----------------------+\n| GET_LOCK(''lock1'',10) |\n+----------------------+\n|                    1 |\n+----------------------+\n\nSELECT RELEASE_ALL_LOCKS();\n+---------------------+\n| RELEASE_ALL_LOCKS() | \n+---------------------+\n|                   1 |\n+---------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/release_all_locks', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/release_all_locks');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (333, 14, 'RELEASE\\_LOCK', 'Syntax\n------\n\nRELEASE_LOCK(str)\n\nDescription\n-----------\n\nReleases the lock named by the string str that was obtained with GET_LOCK(). Returns 1 if the lock was released, 0 if the lock was not established by this connection (in which case the lock is not released), and NULL if the named lock did not exist. The lock does not exist if it was never obtained by a call to GET_LOCK() or if it has previously been released.\n\nstr is case insensitive. If str is an empty string or NULL, RELEASE_LOCK() returns NULL and does nothing.\n\nStatements using the RELEASE_LOCK function are not safe for statement-based replication.\n\nThe DO statement is convenient to use with RELEASE_LOCK().\n\nExamples\n--------\n\nSELECT GET_LOCK(''lock1'',10);\n+----------------------+\n| GET_LOCK(''lock1'',10) |\n+----------------------+\n|                    1 |\n+----------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/release_lock', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/release_lock');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (334, 14, 'SLEEP', 'Syntax\n------\n\nSLEEP(duration)\n\nDescription\n-----------\n\nSleeps (pauses) for the number of seconds given by the duration argument, then returns 0. If SLEEP() is interrupted, it returns 1. The duration may have a fractional part given in microseconds.\n\nStatements using the SLEEP() function are not safe for statement-based replication.\n\nExamples\n--------\n\nSELECT SLEEP(5.5);\n+------------+\n| SLEEP(5.5) |\n+------------+\n|          0 |\n+------------+\n1 row in set (5.50 sec)\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/sleep', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/sleep');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (335, 14, 'SYS\\_GUID', 'Syntax\n------\n\nSYS_GUID()\n\nDescription\n-----------\n\nReturns a 16-byte globally unique identifier (GUID), similar to the UUID function, but without the - character.\n\nExamples\n--------\n\nSELECT SYS_GUID();\n+----------------------------------+\n| SYS_GUID()                       |\n+----------------------------------+\n| 2C574E45BA2811EBB265F859713E4BE4 |\n+----------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/sys_guid', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/sys_guid');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (336, 14, 'UUID', 'Syntax\n------\n\nUUID()\n\nDescription\n-----------\n\nReturns a Universally Unique Identifier (UUID) version 1. Functions to generate v4 and v7 UUIDs are available from MariaDB 11.7. See UUIDv4 and UUIDv7 respectively.\n\nA UUID is designed as a number that is globally unique in space and time. Two calls to UUID() are expected to generate two different values, even if these calls are performed on two separate computers that are not connected to each other.\n\nUUID() results are intended to be unique, but cannot always be relied upon to be unpredictable and unguessable.\n\nA UUID is a 128-bit number represented by a utf8 string of five hexadecimal numbers in aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee format:\n\n The first three numbers are generated from a timestamp.\n The fourth number preserves temporal uniqueness in case the timestamp value\\\n  loses monotonicity (for example, due to daylight saving time).\n* The fifth number is an IEEE 802 node number that provides spatial uniqueness.\\\n  A random number is substituted if the latter is not available (for example,\\\n  because the host computer has no Ethernet card, or we do not know how to find\\\n  the hardware address of an interface on your operating system). In this case,\\\n  spatial uniqueness cannot be guaranteed. Nevertheless, a collision should\\\n  have very low probability.\n\nCurrently, the MAC address of an interface is taken into account only on FreeBSD and Linux. On other operating systems, MariaDB uses a randomly generated 48-bit number.\n\nStatements using the UUID() function are not safe for statement-based replication.\n\nThe function generates a UUIDv1 and the results are generated according to the "DCE 1.1:Remote Procedure Call" (Appendix A) CAE (Common Applications Environment) Specifications published by The Open Group in October 1997 (Document Number C706).\n\nExamples\n--------\n\nSELECT UUID();\n+--------------------------------------+\n| UUID()                               |\n+--------------------------------------+\n| cd41294a-afb0-11df-bc9b-00241dd75637 |\n+--------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/uuid', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/uuid');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (337, 14, 'UUID\\_SHORT', 'Syntax\n------\n\nUUID_SHORT()\n\nDescription\n-----------\n\nReturns a "short" universally unique identifier as a 64-bit unsigned integer (rather than a string-form 128-bit identifier as returned by the UUID() function).\n\nThe value of UUID_SHORT() is guaranteed to be unique if the following conditions hold:\n\n The server_id of the current host is unique among your set of master and slave servers.\n server_id is between 0 and 255.\n You don''t set back your system time for your server between mariadbd restarts.\n You do not invoke UUID_SHORT() on average more than 16 million times per second between mariadbd restarts\n\nThe UUID_SHORT() return value is constructed this way:\n\n``sql\n(server_id & 255) << 56\n+ (server_startup_time_in_seconds << 24)\n+ incremented_variable++;\n``\n\nStatements using the UUID_SHORT() function are not safe for statement-based replication.\n\nExamples\n--------\n\nSELECT UUID_SHORT();\n+-------------------+\n| UUID_SHORT()      |\n+-------------------+\n| 21517162376069120 |\n+-------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/uuid_short', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/uuid_short');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (338, 14, 'UUID\\_v4', 'Syntax\n------\n\nUUID_v4()\n\nDescription\n-----------\n\nReturns a Universally Unique Identifier (UUID) version 4. To generate a version 1 UUID, see the UUID function. To generate a version 7 UUID, see UUIDv7.\n\nA UUID is designed as a number that is globally unique in space and time. Two calls to UUID() are expected to generate two different values, even if these calls are performed on two separate computers that are not connected to each other.\n\nUUID_v4() results are intended to be unique, but cannot always be relied upon to be unpredictable and unguessable.\n\nA UUID is a 128-bit number represented by a utf8 string of five hexadecimal numbers in aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee format.\n\nStatements using the UUID_v4() function are not safe for statement-based replication.\n\nExamples\n--------\n\nSELECT UUID(),UUID_v4(),UUID_v7()\\G \n************************ 1. row ************************\n  UUID(): 63ae8c92-799a-11ef-98b2-f859713e4be4\nUUID_v4(): a2443495-1b94-415b-b6fa-fe8e79ba4812\nUUID_v7(): 01921e85-f198-7490-9b89-7dd0d468543b\n\nCREATE TABLE t1 (a INT PRIMARY KEY NOT NULL, u UUID DEFAULT UUID_v4(), UNIQUE KEY(u));\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/uuid_v4', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/uuid_v4');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (339, 14, 'UUID\\_v7', 'Syntax\n------\n\nUUID_v7()\n\nDescription\n-----------\n\nReturns a Universally Unique Identifier (UUID) version 7. To generate a version 1 UUID, see the UUID function. To generate a version 4 UUID, see UUID_v4.\n\nA UUID is designed as a number that is globally unique in space and time. Two calls to UUID() are expected to generate two different values, even if these calls are performed on two separate computers that are not connected to each other.\n\nA UUID is a 128-bit number represented by a utf8 string of five hexadecimal numbers in aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee format.\n\nStatements using the UUID_v7() function are not safe for statement-based replication.\n\nExamples\n--------\n\nSELECT UUID(),UUID_v4(),UUID_v7()\\G \n************************ 1. row ************************\n  UUID(): 63ae8c92-799a-11ef-98b2-f859713e4be4\nUUID_v4(): a2443495-1b94-415b-b6fa-fe8e79ba4812\nUUID_v7(): 01921e85-f198-7490-9b89-7dd0d468543b\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/uuid_v7', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/uuid_v7');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (340, 14, 'VALUES / VALUE', 'Syntax\n------\n\nVALUE(col_name)\n\nDescription\n-----------\n\nIn an INSERT ... ON DUPLICATE KEY UPDATE statement, you can use the VALUES(col_name) function in the UPDATE clause to refer to column values from the INSERT portion of the statement. In other words, VALUES(col_name) in the UPDATE clause refers to the value of col_name that would be inserted, had no duplicate-key conflict occurred. This function is especially useful in multiple-row inserts.\n\nThe VALUES() function is meaningful only in INSERT ... ON DUPLICATE KEY UPDATE statements and returns NULL otherwise.\n\nThis function was renamed to VALUE(), because it''s incompatible with the standard Table Value Constructors syntax.\n\nThe VALUES() function can still be used but only in INSERT ... ON DUPLICATE KEY UPDATE statements; it''s a syntax error otherwise.\n\nExamples\n--------\n\nINSERT INTO t (a,b,c) VALUES (1,2,3),(4,5,6)\n    ON DUPLICATE KEY UPDATE c=VALUE(a)+VALUE(b);\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/values-value', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/values-value');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (341, 35, 'COLUMN\\_ADD', 'Syntax\n------\n\nCOLUMN_ADD(dyncol_blob, column_nr, value [as type], [column_nr, value [as type]]...)\nCOLUMN_ADD(dyncol_blob, column_name, value [as type], [column_name, value [as type]]...)\n\nDescription\n-----------\n\nAdds or updates dynamic columns.\n\n dyncol_blob must be either a valid dynamic columns blob (for example, COLUMN_CREATE returns such blob), or an empty string.\n column_name specifies the name of the column to be added. If dyncol_blob already has a column with this name, it will be overwritten.\n value specifies the new value for the column. Passing a NULL value will cause the column to be deleted.\n as type is optional. See #datatypes section for a discussion about types.\n\nThe return value is a dynamic column blob after the modifications.\n\nExamples\n--------\n\nUPDATE t1 SET dyncol_blob=COLUMN_ADD(dyncol_blob, "column_name", "value") WHERE id=1;\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_add', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_add');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (342, 35, 'COLUMN\\_CHECK', 'Syntax\n------\n\nCOLUMN_CHECK(dyncol_blob);\n\nDescription\n-----------\n\nCheck if dyncol_blob is a valid packed dynamic columns blob. Return value of 1 means the blob is valid, return value of 0 means it is not.\n\nRationale:\\\nNormally, one works with valid dynamic column blobs. Functions like COLUMN_CREATE, COLUMN_ADD, COLUMN_DELETE always return valid dynamic column blobs. However, if a dynamic column blob is accidentally truncated, or transcoded from one character set to another, it will be corrupted. This function can be used to check if a value in a blob field is a valid dynamic column blob.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_check', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_check');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (343, 35, 'COLUMN\\_CREATE', 'Syntax\n------\n\nCOLUMN_CREATE(column_nr, value [as type], [column_nr, value [as type]]...)\nCOLUMN_CREATE(column_name, value [as type], [column_name, value [as type]]...)\n\nDescription\n-----------\n\nReturns a dynamic columns blob that stores the specified columns with values.\n\nThe return value is suitable for\n\n storing in a table;\n further modification with other dynamic columns functions.\n\nThe as type part allows one to specify the value type. In most cases, this is redundant because MariaDB will be able to deduce the type of the value. Explicit type specification may be needed when the type of the value is not apparent. For example, a literal ''2012-12-01'' has a CHAR type by default, one will need to specify ''2012-12-01'' AS DATE to have it stored as a date. See Dynamic Columns:Datatypes for further details.\n\nExamples\n--------\n\nINSERT INTO tbl SET dyncol_blob=COLUMN_CREATE("column_name", "value");\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_create', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_create');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (344, 35, 'COLUMN\\_DELETE', 'Syntax\n------\n\nCOLUMN_DELETE(dyncol_blob, column_nr, column_nr...)\nCOLUMN_DELETE(dyncol_blob, column_name, column_name...)\n\nDescription\n-----------\n\nDeletes a dynamic column with the specified name. Multiple names can be given. The return value is a dynamic column blob after the modification.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_delete', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_delete');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (345, 35, 'COLUMN\\_EXISTS', 'Syntax\n------\n\nCOLUMN_EXISTS(dyncol_blob, column_nr)\nCOLUMN_EXISTS(dyncol_blob, column_name)\n\nDescription\n-----------\n\nChecks if a column with name column_name exists in dyncol_blob. If yes, return 1, otherwise return 0. See dynamic columns for more information.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_exists', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_exists');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (346, 35, 'COLUMN\\_GET', 'Syntax\n------\n\nCOLUMN_GET(dyncol_blob, column_nr as type)\nCOLUMN_GET(dyncol_blob, column_name as type)\n\nDescription\n-----------\n\nGets the value of a dynamic column by its name. If no column with the given name exists, NULL will be returned.\n\ncolumn_name as type requires that one specify the datatype of the dynamic column they are reading.\n\nThis may seem counter-intuitive: why would one need to specify which datatype they''re retrieving? Can''t the dynamic columns system figure the datatype from the data being stored?\n\nThe answer is: SQL is a statically-typed language. The SQL interpreter needs to know the datatypes of all expressions before the query is run (for example, when one is using prepared statements and runs "select COLUMN_GET(...)", the prepared statement API requires the server to inform the client about the datatype of the column being read before the query is executed and the server can see what datatype the column actually has).\n\nLengths\n\nSuppose running a query like this:\n\n``sql\nSELECT COLUMN_GET(BLOB, ''colname'' AS CHAR) ...\n`\n\nWithout specifying a maximum length (i.e. using as CHAR, not as CHAR(n)`), MariaDB will report the maximum length of the result set column to be 16,777,216. This may cause excessive memory usage in some client libraries, because they try to pre-allocate a buffer of maximum result set width. To avoid this problem, use CHAR(n) whenever you''re using COLUMN_GET in the select list.\n\nSee Dynamic Columns:Datatypes for more information about datatypes.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_get', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_get');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (347, 35, 'COLUMN\\_JSON', 'Syntax\n------\n\nCOLUMN_JSON(dyncol_blob)\n\nDescription\n-----------\n\nReturns a JSON representation of data in dyncol_blob. Can also be used to display nested columns. See dynamic columns for more information.\n\nExamples\n--------\n\nSELECT item_name, COLUMN_JSON(dynamic_cols) FROM assets;\n+-----------------+----------------------------------------+\n| item_name       | COLUMN_JSON(dynamic_cols)              |\n+-----------------+----------------------------------------+\n| MariaDB T-shirt | {"size":"XL","color":"blue"}           |\n| Thinkpad Laptop | {"color":"black","warranty":"3 years"} |\n+-----------------+----------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_json', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_json');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (348, 35, 'COLUMN\\_LIST', 'Syntax\n------\n\nCOLUMN_LIST(dyncol_blob);\n\nDescription\n-----------\n\nReturns a comma-separated list of column names. The names are quoted with backticks.\n\nSee dynamic columns for more information.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_list', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_list');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (349, 35, 'WSREP\\_LAST\\_SEEN\\_GTID', 'Syntax\n------\n\nWSREP_LAST_SEEN_GTID()\n\nDescription\n-----------\n\nReturns the Global Transaction ID of the most recent write transaction observed by the client.\n\nThe result can be useful to determine the transaction to provide to WSREP_SYNC_WAIT_UPTO_GTID for waiting and unblocking purposes.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/galera-functions/wsrep_last_seen_gtid', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/galera-functions/wsrep_last_seen_gtid');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (350, 35, 'WSREP\\_LAST\\_WRITTEN\\_GTID', 'Syntax\n------\n\nWSREP_LAST_WRITTEN_GTID()\n\nDescription\n-----------\n\nReturns the Global Transaction ID of the most recent write transaction performed by the client.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/galera-functions/wsrep_last_written_gtid', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/galera-functions/wsrep_last_written_gtid');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (351, 35, 'WSREP\\_SYNC\\_WAIT\\_UPTO\\_GTID', 'Syntax\n------\n\nWSREP_SYNC_WAIT_UPTO_GTID(gtid[,timeout])\n\nDescription\n-----------\n\nBlocks the client until the transaction specified by the given Global Transaction ID is applied and committed by the node.\n\nThe optional _timeout_ argument can be used to specify a block timeout in seconds. If not provided, the timeout will be indefinite.\n\nReturns the node that applied and committed the Global Transaction ID, ER_LOCAL_WAIT_TIMEOUT if the function is timed out before this, or ER_WRONG_ARGUMENTS if the function is given an invalid GTID.\n\nThe result from WSREP_LAST_SEEN_GTID can be useful to determine the transaction to provide to WSREP_SYNC_WAIT_UPTO_GTID for waiting and unblocking purposes.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/galera-functions/wsrep_sync_wait_upto_gtid', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/galera-functions/wsrep_sync_wait_upto_gtid');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (352, 35, 'Geographic Functions', 'Description\n-----------\n\nGeographic and geometry functions. See Geographic Features for a full discussion of MariaDB''s spatial extensions.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/geographic-functions', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/geographic-functions');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (353, 35, 'Differences between JSON\\_QUERY and JSON\\_VALUE', 'Description\n-----------\n\nThe primary difference between the two functions is that _JSON_QUERY_ returns an object or an array, while _JSON_VALUE_ returns a scalar.\n\nTake the following JSON document as an example:\n\n``sql\nSET @json=''{ "x": [0,1], "y": "[0,1]", "z": "Monty" }'';\n`\n\nNote that data member "x" is an array, and data members "y" and "z" are strings. The following examples demonstrate the differences between the two functions.\n\n`sql\nSELECT JSON_QUERY(@json,''$''), JSON_VALUE(@json,''$'');\n+--------------------------------------------+-----------------------+\n| JSON_QUERY(@json,''$'')                      | JSON_VALUE(@json,''$'') |\n+--------------------------------------------+-----------------------+\n| { "x": [0,1], "y": "[0,1]", "z": "Monty" } | NULL                  |\n+--------------------------------------------+-----------------------+\n\nSELECT JSON_QUERY(@json,''$.x''), JSON_VALUE(@json,''$.x'');\n+-------------------------+-------------------------+\n| JSON_QUERY(@json,''$.x'') | JSON_VALUE(@json,''$.x'') |\n+-------------------------+-------------------------+\n| [0,1]                   | NULL                    |\n+-------------------------+-------------------------+\n\nSELECT JSON_QUERY(@json,''$.y''), JSON_VALUE(@json,''$.y'');\n+-------------------------+-------------------------+\n| JSON_QUERY(@json,''$.y'') | JSON_VALUE(@json,''$.y'') |\n+-------------------------+-------------------------+\n| NULL                    | [0,1]                   |\n+-------------------------+-------------------------+\n\nSELECT JSON_QUERY(@json,''$.z''), JSON_VALUE(@json,''$.z'');\n+-------------------------+-------------------------+\n| JSON_QUERY(@json,''$.z'') | JSON_VALUE(@json,''$.z'') |\n+-------------------------+-------------------------+\n| NULL                    | Monty                   |\n+-------------------------+-------------------------+\n\nSELECT JSON_QUERY(@json,''$.x[0]''), JSON_VALUE(@json,''$.x[0]'');\n+----------------------------+----------------------------+\n| JSON_QUERY(@json,''$.x[0]'') | JSON_VALUE(@json,''$.x[0]'') |\n+----------------------------+----------------------------+\n| NULL                       | 0                          |\n+----------------------------+----------------------------+\n``\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/differences-between-json_query-and-json_value', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/differences-between-json_query-and-json_value');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (354, 35, 'JSON Validation Function', 'Description\n-----------\n\nThe IS JSON is a variant of IS predicate that checks whether an expression contains valid JSON data, with optional constraints on JSON type (VALUE, ARRAY, OBJECT, SCALAR) and key uniqueness.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json-validation-function', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json-validation-function');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (355, 35, 'JSON\\_ARRAY', 'Syntax\n------\n\nJSON_ARRAY([value[, value2] ...])\n\nDescription\n-----------\n\nReturns a JSON array containing the listed values. The list can be empty.\n\nExamples\n--------\n\nSELECT Json_Array(56, 3.1416, ''My name is "Foo"'', NULL);\n+--------------------------------------------------+\n| Json_Array(56, 3.1416, ''My name is "Foo"'', NULL) |\n+--------------------------------------------------+\n| [56, 3.1416, "My name is \\"Foo\\"", null]         |\n+--------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_array', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_array');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (356, 35, 'JSON\\_ARRAY\\_APPEND', 'Syntax\n------\n\nJSON_ARRAY_APPEND(json_doc, path, value[, path, value] ...)\n\nDescription\n-----------\n\nAppends values to the end of the specified arrays within a JSON document, returning the result, or NULL if any of the arguments are NULL.\n\nEvaluation is performed from left to right, with the resulting document from the previous pair becoming the new value against which the next pair is evaluated.\n\nIf the json_doc is not a valid JSON document, or if any of the paths are not valid, or contain a  or * wildcard, an error is returned.\n\nExamples\n--------\n\nSET @json = ''[1, 2, [3, 4]]'';\n\nSELECT JSON_ARRAY_APPEND(@json, ''$[0]'', 5)\n+-------------------------------------+\n| JSON_ARRAY_APPEND(@json, ''$[0]'', 5) |\n+-------------------------------------+\n| [[1, 5], 2, [3, 4]]                 |\n+-------------------------------------+\n\nSELECT JSON_ARRAY_APPEND(@json, ''$[1]'', 6);\n+-------------------------------------+\n| JSON_ARRAY_APPEND(@json, ''$[1]'', 6) |\n+-------------------------------------+\n| [1, [2, 6], [3, 4]]                 |\n+-------------------------------------+\n\nSELECT JSON_ARRAY_APPEND(@json, ''$[1]'', 6, ''$[2]'', 7);\n+------------------------------------------------+\n| JSON_ARRAY_APPEND(@json, ''$[1]'', 6, ''$[2]'', 7) |\n+------------------------------------------------+\n| [1, [2, 6], [3, 4, 7]]                         |\n+------------------------------------------------+\n\nSELECT JSON_ARRAY_APPEND(@json, ''$'', 5);\n+----------------------------------+\n| JSON_ARRAY_APPEND(@json, ''$'', 5) |\n+----------------------------------+\n| [1, 2, [3, 4], 5]                |\n+----------------------------------+\n\nSET @json = ''{"A": 1, "B": [2], "C": [3, 4]}'';\n\nSELECT JSON_ARRAY_APPEND(@json, ''$.B'', 5);\n+------------------------------------+\n| JSON_ARRAY_APPEND(@json, ''$.B'', 5) |\n+------------------------------------+\n| {"A": 1, "B": [2, 5], "C": [3, 4]} |\n+------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_array_append', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_array_append');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (357, 35, 'JSON\\_ARRAY\\_INSERT', 'Syntax\n------\n\nJSON_ARRAY_INSERT(json_doc, path, value[, path, value] ...)\n\nDescription\n-----------\n\nInserts a value into a JSON document, returning the modified document, or NULL if any of the arguments are NULL.\n\nEvaluation is performed from left to right, with the resulting document from the previous pair becoming the new value against which the next pair is evaluated.\n\nIf the json_doc is not a valid JSON document, or if any of the paths are not valid, or contain a  or * wildcard, an error is returned.\n\nExamples\n--------\n\nSET @json = ''[1, 2, [3, 4]]'';\n\nSELECT JSON_ARRAY_INSERT(@json, ''$[0]'', 5);\n+-------------------------------------+\n| JSON_ARRAY_INSERT(@json, ''$[0]'', 5) |\n+-------------------------------------+\n| [5, 1, 2, [3, 4]]                   |\n+-------------------------------------+\n\nSELECT JSON_ARRAY_INSERT(@json, ''$[1]'', 6);\n+-------------------------------------+\n| JSON_ARRAY_INSERT(@json, ''$[1]'', 6) |\n+-------------------------------------+\n| [1, 6, 2, [3, 4]]                   |\n+-------------------------------------+\n\nSELECT JSON_ARRAY_INSERT(@json, ''$[1]'', 6, ''$[2]'', 7);\n+------------------------------------------------+\n| JSON_ARRAY_INSERT(@json, ''$[1]'', 6, ''$[2]'', 7) |\n+------------------------------------------------+\n| [1, 6, 7, 2, [3, 4]]                           |\n+------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_array_insert', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_array_insert');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (358, 35, 'JSON\\_ARRAY\\_INTERSECT', 'Syntax\n------\n\nJSON_ARRAY_INTERSECT(arr1, arr2)\n\nDescription\n-----------\n\nFinds intersection between two json arrays and returns an array of items found in both array.\n\nExamples\n--------\n\nSET @json1= ''[1,2,3]'';\nSET @json2= ''[1,2,4]'';\n\nSELECT json_array_intersect(@json1, @json2); \n+--------------------------------------+\n| json_array_intersect(@json1, @json2) |\n+--------------------------------------+\n| [1, 2]                               |\n+--------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_array_intersect', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_array_intersect');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (359, 35, 'JSON\\_ARRAYAGG', 'Syntax\n------\n\nJSON_ARRAYAGG(column_or_expression)\n\nDescription\n-----------\n\nJSON_ARRAYAGG returns a JSON array containing an element for each value in a given set of JSON or SQL values. It acts on a column or an expression that evaluates to a single value.\n\nThe maximum returned length in bytes is determined by the group_concat_max_len server system variable.\n\nReturns NULL in the case of an error, or if the result contains no rows.\n\nJSON_ARRAYAGG cannot currently be used as a window function.\n\nThe full syntax is as follows:\n\n``sql\nJSON_ARRAYAGG([DISTINCT] expr\n             [ORDER BY {unsigned_integer | col_name | expr}\n                 [ASC | DESC] [,col_name ...]]\n             [LIMIT {[offset,] row_count | row_count OFFSET offset}])\n``\n\nExamples\n--------\n\nCREATE TABLE t1 (a INT, b INT);\n\nINSERT INTO t1 VALUES (1, 1),(2, 1), (1, 1),(2, 1), (3, 2),(2, 2),(2, 2),(2, 2);\n\nSELECT JSON_ARRAYAGG(a), JSON_ARRAYAGG(b) FROM t1;\n+-------------------+-------------------+\n| JSON_ARRAYAGG(a)  | JSON_ARRAYAGG(b)  |\n+-------------------+-------------------+\n| [1,2,1,2,3,2,2,2] | [1,1,1,1,2,2,2,2] |\n+-------------------+-------------------+\n\nSELECT JSON_ARRAYAGG(a), JSON_ARRAYAGG(b) FROM t1 GROUP BY b;\n+------------------+------------------+\n| JSON_ARRAYAGG(a) | JSON_ARRAYAGG(b) |\n+------------------+------------------+\n| [1,2,1,2]        | [1,1,1,1]        |\n| [3,2,2,2]        | [2,2,2,2]        |\n+------------------+------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_arrayagg', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_arrayagg');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (360, 35, 'JSON\\_COMPACT', 'Syntax\n------\n\nJSON_COMPACT(json_doc)\n\nDescription\n-----------\n\nRemoves all unnecessary spaces so the json document is as short as possible.\n\nExamples\n--------\n\nSET @j = ''{ "A": 1, "B": [2, 3]}'';\n\nSELECT JSON_COMPACT(@j), @j;\n+-------------------+------------------------+\n| JSON_COMPACT(@j)  | @j                     |\n+-------------------+------------------------+\n| {"A":1,"B":[2,3]} | { "A": 1, "B": [2, 3]} |\n+-------------------+------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_compact', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_compact');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (361, 35, 'JSON\\_CONTAINS', 'Syntax\n------\n\nJSON_CONTAINS(json_doc, val[, path])\n\nDescription\n-----------\n\nReturns whether or not the specified value is found in the given JSON document or, optionally, at the specified path within the document. Returns 1 if it does, 0 if not and NULL if any of the arguments are null. An error occurs if the document or path is not valid, or contains the  or * wildcards.\n\nExamples\n--------\n\nSET @json = ''{"A": 0, "B": {"C": 1}, "D": 2}'';\n\nSELECT JSON_CONTAINS(@json, ''2'', ''$.A'');\n+----------------------------------+\n| JSON_CONTAINS(@json, ''2'', ''$.A'') |\n+----------------------------------+\n|                                0 |\n+----------------------------------+\n\nSELECT JSON_CONTAINS(@json, ''2'', ''$.D'');\n+----------------------------------+\n| JSON_CONTAINS(@json, ''2'', ''$.D'') |\n+----------------------------------+\n|                                1 |\n+----------------------------------+\n\nSELECT JSON_CONTAINS(@json, ''{"C": 1}'', ''$.A'');\n+-----------------------------------------+\n| JSON_CONTAINS(@json, ''{"C": 1}'', ''$.A'') |\n+-----------------------------------------+\n|                                       0 |\n+-----------------------------------------+\n\nSELECT JSON_CONTAINS(@json, ''{"C": 1}'', ''$.B'');\n+-----------------------------------------+\n| JSON_CONTAINS(@json, ''{"C": 1}'', ''$.B'') |\n+-----------------------------------------+\n|                                       1 |\n+-----------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_contains', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_contains');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (362, 35, 'JSON\\_CONTAINS\\_PATH', 'Syntax\n------\n\nJSON_CONTAINS_PATH(json_doc, return_arg, path[, path] ...)\n\nDescription\n-----------\n\nIndicates whether the given JSON document contains data at the specified path or paths. Returns 1 if it does, 0 if not and NULL if any of the arguments are null.\n\nThe _return_arg_ can be one or all:\n\n one - Returns 1 if at least one path exists within the JSON document.\n all - Returns 1 only if all paths exist within the JSON document.\n\nExamples\n--------\n\nSET @json = ''{"A": 1, "B": [2], "C": [3, 4]}'';\n\nSELECT JSON_CONTAINS_PATH(@json, ''one'', ''$.A'', ''$.D'');\n+------------------------------------------------+\n| JSON_CONTAINS_PATH(@json, ''one'', ''$.A'', ''$.D'') |\n+------------------------------------------------+\n|                                              1 |\n+------------------------------------------------+\n1 row in set (0.00 sec)\n\nSELECT JSON_CONTAINS_PATH(@json, ''all'', ''$.A'', ''$.D'');\n+------------------------------------------------+\n| JSON_CONTAINS_PATH(@json, ''all'', ''$.A'', ''$.D'') |\n+------------------------------------------------+\n|                                              0 |\n+------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_contains_path', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_contains_path');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (363, 35, 'JSON\\_DEPTH', 'Syntax\n------\n\nJSON_DEPTH(json_doc)\n\nDescription\n-----------\n\nReturns the maximum depth of the given JSON document, or NULL if the argument is null. An error occurs if the argument is an invalid JSON document.\n\n Scalar values or empty arrays or objects have a depth of 1.\n Arrays with only scalar values and objects with only scalar values for all keys have depth of 1.\n* In all other cases, the depth can be 2 or greater.\n\nThere is no maximum depth level — it''s unlimited.\n\nFor more information, see this blog post.\n\nThe maximum depth is 32.\n\nExamples\n--------\n\nSELECT JSON_DEPTH(''[]''), JSON_DEPTH(''true''), JSON_DEPTH(''{}'');\n+------------------+--------------------+------------------+\n| JSON_DEPTH(''[]'') | JSON_DEPTH(''true'') | JSON_DEPTH(''{}'') |\n+------------------+--------------------+------------------+\n|                1 |                  1 |                1 |\n+------------------+--------------------+------------------+\n\nSELECT JSON_DEPTH(''[1, 2, 3]''), JSON_DEPTH(''[[], {}, []]'');\n+-------------------------+----------------------------+\n| JSON_DEPTH(''[1, 2, 3]'') | JSON_DEPTH(''[[], {}, []]'') |\n+-------------------------+----------------------------+\n|                       2 |                          2 |\n+-------------------------+----------------------------+\n\nSELECT JSON_DEPTH(''[1, 2, [3, 4, 5, 6], 7]'');\n+---------------------------------------+\n| JSON_DEPTH(''[1, 2, [3, 4, 5, 6], 7]'') |\n+---------------------------------------+\n|                                     3 |\n+---------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_depth', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_depth');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (364, 35, 'JSON\\_DETAILED', 'Syntax\n------\n\nJSON_DETAILED(json_doc[, tab_size])\nJSON_PRETTY(json_doc[, tab_size])\n\nDescription\n-----------\n\nRepresents JSON in the most understandable way emphasizing nested structures.\n\nJSON_PRETTY is an alias for JSON_DETAILED .\n\nJSON_PRETTY is not available as an alias for JSON_DETAILED .\n\nExamples\n--------\n\nSET @j = ''{ "A":1,"B":[2,3]}'';\n\nSELECT @j;\n+--------------------+\n| @j                 |\n+--------------------+\n| { "A":1,"B":[2,3]} |\n+--------------------+\n\nSELECT JSON_DETAILED(@j);\n+------------------------------------------------------------+\n| JSON_DETAILED(@j)                                          |\n+------------------------------------------------------------+\n| {\n    "A": 1,\n    "B": \n    [\n        2,\n        3\n    ]\n} |\n+------------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_detailed', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_detailed');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (365, 35, 'JSON\\_EQUALS', 'Syntax\n------\n\nJSON_EQUALS(json1, json2)\n\nDescription\n-----------\n\nChecks if there is equality between two json objects. Returns 1 if it there is, 0 if not, or NULL if any of the arguments are null.\n\nExamples\n--------\n\nSELECT JSON_EQUALS(''{"a"   :[1, 2, 3],"b":[4]}'', ''{"b":[4],"a":[1, 2, 3.0]}'');\n+------------------------------------------------------------------------+\n| JSON_EQUALS(''{"a"   :[1, 2, 3],"b":[4]}'', ''{"b":[4],"a":[1, 2, 3.0]}'') |\n+------------------------------------------------------------------------+\n|                                                                      1 |\n+------------------------------------------------------------------------+\n\nSELECT JSON_EQUALS(''{"a":[1, 2, 3]}'', ''{"a":[1, 2, 3.01]}'');\n+------------------------------------------------------+\n| JSON_EQUALS(''{"a":[1, 2, 3]}'', ''{"a":[1, 2, 3.01]}'') |\n+------------------------------------------------------+\n|                                                    0 |\n+------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_equals', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_equals');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (366, 35, 'JSON\\_EXISTS', 'Syntax\n------\n\nJSON_EXISTS(json_doc, json_path)\n\nDescription\n-----------\n\nDetermines whether json_doc has an element pointed to by path json_path. Returns 1 if the element exists, 0 if not, or NULL if any of the inputs were NULL.\n\nExamples\n--------\n\nSELECT JSON_EXISTS(''{"key1":"xxxx", "key2":[1, 2, 3]}'', "$.key2");\n+------------------------------------------------------------+\n| JSON_EXISTS(''{"key1":"xxxx", "key2":[1, 2, 3]}'', "$.key2") |\n+------------------------------------------------------------+\n|                                                          1 |\n+------------------------------------------------------------+\n\nSELECT JSON_EXISTS(''{"key1":"xxxx", "key2":[1, 2, 3]}'', "$.key3");\n+------------------------------------------------------------+\n| JSON_EXISTS(''{"key1":"xxxx", "key2":[1, 2, 3]}'', "$.key3") |\n+------------------------------------------------------------+\n|                                                          0 |\n+------------------------------------------------------------+\n\nSELECT JSON_EXISTS(''{"key1":"xxxx", "key2":[1, 2, 3]}'', "$.key2[1]");\n+---------------------------------------------------------------+\n| JSON_EXISTS(''{"key1":"xxxx", "key2":[1, 2, 3]}'', "$.key2[1]") |\n+---------------------------------------------------------------+\n|                                                             1 |\n+---------------------------------------------------------------+\n\nSELECT JSON_EXISTS(''{"key1":"xxxx", "key2":[1, 2, 3]}'', "$.key2[10]");\n+----------------------------------------------------------------+\n| JSON_EXISTS(''{"key1":"xxxx", "key2":[1, 2, 3]}'', "$.key2[10]") |\n+----------------------------------------------------------------+\n|                                                              0 |\n+----------------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_exists', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_exists');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (367, 35, 'JSON\\_EXTRACT', 'Syntax\n------\n\nJSON_EXTRACT(json_doc, path[, path] ...)\n\nDescription\n-----------\n\nExtracts data from a JSON document. The extracted data is selected from the parts matching the path arguments. Returns all matched values; either as a single matched value, or, if the arguments could return multiple values, a result autowrapped as an array in the matching order.\n\nReturns NULL if no paths match or if any of the arguments are NULL.\n\nAn error occurs if any path argument is not a valid path, or if the json_doc argument is not a valid JSON document.\n\nThe path expression be a JSONPath expression as supported by MariaDB\n\nExamples\n--------\n\nSET @json = ''[1, 2, [3, 4]]'';\n\nSELECT JSON_EXTRACT(@json, ''$[1]'');\n+-----------------------------+\n| JSON_EXTRACT(@json, ''$[1]'') |\n+-----------------------------+\n| 2                           |\n+-----------------------------+\n\nSELECT JSON_EXTRACT(@json, ''$[2]'');\n+-----------------------------+\n| JSON_EXTRACT(@json, ''$[2]'') |\n+-----------------------------+\n| [3, 4]                      |\n+-----------------------------+\n\nSELECT JSON_EXTRACT(@json, ''$[2][1]'');\n+--------------------------------+\n| JSON_EXTRACT(@json, ''$[2][1]'') |\n+--------------------------------+\n| 4                              |\n+--------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_extract', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_extract');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (368, 35, 'JSON\\_INSERT', 'Syntax\n------\n\nJSON_INSERT(json_doc, path, val[, path, val] ...)\n\nDescription\n-----------\n\nInserts data into a JSON document, returning the resulting document or NULL if either of the _json_doc_ or _path_ arguments are null.\n\nAn error occurs if the JSON document is invalid, or if any of the paths are invalid or contain a  or * wildcard.\n\nJSON_INSERT can only insert data, while JSON_REPLACE can only update. JSON_SET can update or insert data.\n\nExamples\n--------\n\nSET @json = ''{ "A": 0, "B": [1, 2]}'';\n\nSELECT JSON_INSERT(@json, ''$.C'', ''[3, 4]'');\n+--------------------------------------+\n| JSON_INSERT(@json, ''$.C'', ''[3, 4]'')  |\n+--------------------------------------+\n| { "A": 0, "B": [1, 2], "C":"[3, 4]"} |\n+--------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_insert', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_insert');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (369, 35, 'JSON\\_KEY\\_VALUE', 'Syntax\n------\n\nJSON_KEY_VALUE(obj, json_path)\n\nDescription\n-----------\n\nJSON_KEY_VALUE extracts key/value pairs from a JSON object. The JSON path parameter is used to only return key/value pairs for matching JSON objects.\n\nExamples\n--------\n\nSELECT JSON_KEY_VALUE(''[[1, {"key1":"val1", "key2":"val2"}, 3], 2, 3]'', ''$[0][1]'');\n+-----------------------------------------------------------------------------+\n| JSON_KEY_VALUE(''[[1, {"key1":"val1", "key2":"val2"}, 3], 2, 3]'', ''$[0][1]'') |\n+-----------------------------------------------------------------------------+\n| [{"key": "key1", "value": "val1"}, {"key": "key2", "value": "val2"}]        |\n+-----------------------------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_key_value', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_key_value');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (370, 35, 'JSON\\_KEYS', 'Syntax\n------\n\nJSON_KEYS(json_doc[, path])\n\nDescription\n-----------\n\nReturns the keys as a JSON array from the top-level value of a JSON object or, if the optional path argument is provided, the top-level keys from the path.\n\nExcludes keys from nested sub-objects in the top level value. The resulting array will be empty if the selected object is empty.\n\nReturns NULL if any of the arguments are null, a given path does not locate an object, or if the json_doc argument is not an object.\n\nAn error will occur if JSON document is invalid, the path is invalid or if the path contains a  or * wildcard.\n\nExamples\n--------\n\nSELECT JSON_KEYS(''{"A": 1, "B": {"C": 2}}'');\n+--------------------------------------+\n| JSON_KEYS(''{"A": 1, "B": {"C": 2}}'') |\n+--------------------------------------+\n| ["A", "B"]                           |\n+--------------------------------------+\n\nSELECT JSON_KEYS(''{"A": 1, "B": 2, "C": {"D": 3}}'', ''$.C'');\n+-----------------------------------------------------+\n| JSON_KEYS(''{"A": 1, "B": 2, "C": {"D": 3}}'', ''$.C'') |\n+-----------------------------------------------------+\n| ["D"]                                               |\n+-----------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_keys', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_keys');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (371, 35, 'JSON\\_LENGTH', 'Syntax\n------\n\nJSON_LENGTH(json_doc[, path])\n\nDescription\n-----------\n\nReturns the length of a JSON document, or, if the optional path argument is given, the length of the value within the document specified by the path.\n\nReturns NULL if any of the arguments argument are null or the path argument does not identify a value in the document.\n\nAn error occurs if the JSON document is invalid, the path is invalid or if the path contains a  or  wildcard.\n\nLength will be determined as follow:\n\n A scalar''s length is always 1.\n If an array, the number of elements in the array.\n If an object, the number of members in the object.\n\nThe length of nested arrays or objects are not counted.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_length', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_length');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (372, 35, 'JSON\\_LOOSE', 'Syntax\n------\n\nJSON_LOOSE(json_doc)\n\nDescription\n-----------\n\nAdds spaces to a JSON document to make it look more readable.\n\nExamples\n--------\n\nSET @j = ''{ "A":1,"B":[2,3]}'';\n\nSELECT JSON_LOOSE(@j), @j;\n+-----------------------+--------------------+\n| JSON_LOOSE(@j)        | @j                 |\n+-----------------------+--------------------+\n| {"A": 1, "B": [2, 3]} | { "A":1,"B":[2,3]} |\n+-----------------------+--------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_loose', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_loose');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (373, 35, 'JSON\\_MERGE', 'Syntax\n------\n\nJSON_MERGE(json_doc, json_doc[, json_doc] ...)\n\nDescription\n-----------\n\nMerges the given JSON documents.\n\nReturns the merged result, or NULL if any argument is NULL.\n\nAn error occurs if any of the arguments are not valid JSON documents.\n\nJSON_MERGE is deprecated. JSON_MERGE_PATCH is an RFC 7396-compliant replacement, and JSON_MERGE_PRESERVE is a synonym.\n\nExamples\n--------\n\nSET @json1 = ''[1, 2]'';\nSET @json2 = ''[3, 4]'';\n\nSELECT JSON_MERGE(@json1,@json2);\n+---------------------------+\n| JSON_MERGE(@json1,@json2) |\n+---------------------------+\n| [1, 2, 3, 4]              |\n+---------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_merge', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_merge');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (374, 35, 'JSON\\_MERGE\\_PATCH', 'Syntax\n------\n\nJSON_MERGE_PATCH(json_doc, json_doc[, json_doc] ...)\n\nDescription\n-----------\n\nMerges the given JSON documents, returning the merged result, or NULL if any argument is NULL.\n\nJSON_MERGE_PATCH is an RFC 7396-compliant replacement for JSON_MERGE, which is deprecated.\n\nUnlike JSON_MERGE_PRESERVE, members with duplicate keys are not preserved.\n\nExamples\n--------\n\nSET @json1 = ''[1, 2]'';\nSET @json2 = ''[2, 3]'';\nSELECT JSON_MERGE_PATCH(@json1,@json2),JSON_MERGE_PRESERVE(@json1,@json2);\n+---------------------------------+------------------------------------+\n| JSON_MERGE_PATCH(@json1,@json2) | JSON_MERGE_PRESERVE(@json1,@json2) |\n+---------------------------------+------------------------------------+\n| [2, 3]                          | [1, 2, 2, 3]                       |\n+---------------------------------+------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_merge_patch', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_merge_patch');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (375, 35, 'JSON\\_MERGE\\_PRESERVE', 'Syntax\n------\n\nJSON_MERGE_PRESERVE(json_doc, json_doc[, json_doc] ...)\n\nDescription\n-----------\n\nMerges the given JSON documents, returning the merged result, or NULL if any argument is NULL.\n\nJSON_MERGE_PRESERVE is a synonym for JSON_MERGE, which has been deprecated.\n\nUnlike JSON_MERGE_PATCH, members with duplicate keys are preserved.\n\nExamples\n--------\n\nSET @json1 = ''[1, 2]'';\nSET @json2 = ''[2, 3]'';\nSELECT JSON_MERGE_PATCH(@json1,@json2),JSON_MERGE_PRESERVE(@json1,@json2);\n+---------------------------------+------------------------------------+\n| JSON_MERGE_PATCH(@json1,@json2) | JSON_MERGE_PRESERVE(@json1,@json2) |\n+---------------------------------+------------------------------------+\n| [2, 3]                          | [1, 2, 2, 3]                       |\n+---------------------------------+------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_merge_preserve', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_merge_preserve');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (376, 35, 'JSON\\_NORMALIZE', 'Syntax\n------\n\nJSON_NORMALIZE(json)\n\nDescription\n-----------\n\nRecursively sorts keys and removes spaces, allowing comparison of json documents for equality.\n\nExamples\n--------\n\nCREATE TABLE t1 (\n id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,\n val JSON,\n / other columns here /\n PRIMARY KEY (id)\n);\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_normalize', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_normalize');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (377, 35, 'JSON\\_OBJECT', 'Syntax\n------\n\nJSON_OBJECT([key, value[, key, value] ...])\n\nDescription\n-----------\n\nReturns a JSON object containing the given key/value pairs. The key/value list can be empty.\n\nAn error will occur if there are an odd number of arguments, or any key name is NULL.\n\nExamples\n--------\n\nSELECT JSON_OBJECT("id", 1, "name", "Monty");\n+---------------------------------------+\n| JSON_OBJECT("id", 1, "name", "Monty") |\n+---------------------------------------+\n| {"id": 1, "name": "Monty"}            |\n+---------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_object', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_object');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (378, 35, 'JSON\\_OBJECT\\_FILTER\\_KEYS', 'Syntax\n------\n\nJSON_OBJECT_FILTER_KEYS(obj, array_keys)\n\nDescription\n-----------\n\nJSON_OBJECT_FILTER_KEYS returns a JSON object with keys from the object that are also present in the array as string. It is used when one wants to get key-value pair such that the keys are common but the values may not be common.\n\nExamples\n--------\n\nSET @obj1= ''{ "a": 1, "b": 2, "c": 3}'';\nSET @obj2= ''{"b" : 10, "c": 20, "d": 30}'';\nSELECT JSON_OBJECT_FILTER_KEYS (@obj1, JSON_ARRAY_INTERSECT(JSON_KEYS(@obj1), JSON_KEYS(@obj2)));\n+-------------------------------------------------------------------------------------------+\n| JSON_OBJECT_FILTER_KEYS (@obj1, JSON_ARRAY_INTERSECT(JSON_KEYS(@obj1), JSON_KEYS(@obj2))) |\n+-------------------------------------------------------------------------------------------+\n| {"b": 2, "c": 3}                                                                          |\n+-------------------------------------------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_object_filter_keys', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_object_filter_keys');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (379, 35, 'JSON\\_OBJECT\\_TO\\_ARRAY', 'Syntax\n------\n\nJSON_OBJECT_TO_ARRAY(Obj)\n\nDescription\n-----------\n\nIt is used to convert all JSON objects found in a JSON document to JSON arrays where each item in the outer array represents a single key-value pair from the object. It is used when we want not just common keys, but also common values. It can be used in conjunction with JSON_ARRAY_INTERSECT().\n\nExamples\n--------\n\nSET @obj1= ''{ "a": [1, 2, 3], "b": { "key1":"val1", "key2": {"key3":"val3"} }}'';\n\nSELECT JSON_OBJECT_TO_ARRAY(@obj1);\n+-----------------------------------------------------------------------+\n| JSON_OBJECT_TO_ARRAY(@obj1)                                           |\n+-----------------------------------------------------------------------+\n| [["a", [1, 2, 3]], ["b", {"key1": "val1", "key2": {"key3": "val3"}}]] |\n+-----------------------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_object_to_array', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_object_to_array');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (380, 35, 'JSON\\_OBJECTAGG', 'Syntax\n------\n\nJSON_OBJECTAGG(key, value)\n\nDescription\n-----------\n\nJSON_OBJECTAGG returns a JSON object containing key-value pairs. It takes two expressions that evaluate to a single value, or two column names, as arguments, the first used as a key, and the second as a value.\n\nThe maximum returned length in bytes is determined by the group_concat_max_len server system variable.\n\nReturns NULL in the case of an error, or if the result contains no rows.\n\nJSON_OBJECTAGG cannot currently be used as a window function.\n\nExamples\n--------\n\nSELECT * FROM t1;\n+------+-------+\n| a    | b     |\n+------+-------+\n|    1 | Hello |\n|    1 | World |\n|    2 | This  |\n+------+-------+\n\nSELECT JSON_OBJECTAGG(a, b) FROM t1;\n+----------------------------------------+\n| JSON_OBJECTAGG(a, b)                   |\n+----------------------------------------+\n| {"1":"Hello", "1":"World", "2":"This"} |\n+----------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_objectagg', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_objectagg');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (381, 35, 'JSON\\_OVERLAPS', 'Syntax\n------\n\nJSON_OVERLAPS(json_doc1, json_doc2)\n\nDescription\n-----------\n\nJSON_OVERLAPS() compares two json documents and returns true if they have at least one common\\\nkey-value pair between two objects, array element common between two arrays, or array element common with scalar if one of the arguments is a scalar and other is an array. If two json documents are scalars, it returns true if they have same type and value.\n\nIf none of the above conditions are satisfied then it returns false.\n\nExamples\n--------\n\nSELECT JSON_OVERLAPS(''false'', ''false'');\n+---------------------------------+\n| JSON_OVERLAPS(''false'', ''false'') |\n+---------------------------------+\n| 1                               |\n+---------------------------------+\n\nSELECT JSON_OVERLAPS(''true'', ''["abc", 1, 2, true, false]'');\n+----------------------------------------------------+\n| JSON_OVERLAPS(''true'',''["abc", 1, 2, true, false]'') |\n+----------------------------------------------------+\n| 1                                                  |\n+----------------------------------------------------+\n\nSELECT JSON_OVERLAPS(''{"A": 1, "B": {"C":2}}'', ''{"A": 2, "B": {"C":2}}'') AS is_overlap;\n+---------------------+\n| is_overlap          |\n+---------------------+\n| 1                   |\n+---------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_overlaps', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_overlaps');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (382, 35, 'JSON\\_PRETTY', 'Description\n-----------\n\nJSON_PRETTY is available from MariaDB 10.10.3, 10.9.5, 10.8.7, 10.7.8, 10.6.12, 10.5.19, and 10.4.28.\n\nJSON_PRETTY is an alias for JSON_DETAILED.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_pretty', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_pretty');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (383, 35, 'JSON\\_QUERY', 'Syntax\n------\n\nJSON_QUERY(json_doc, path)\n\nDescription\n-----------\n\nGiven a JSON document, returns an object or array specified by the path. Returns NULL if not given a valid JSON document, or if there is no match.\n\nExamples\n--------\n\nSELECT json_query(''{"key1":{"a":1, "b":[1,2]}}'', ''$.key1'');\n+-----------------------------------------------------+\n| json_query(''{"key1":{"a":1, "b":[1,2]}}'', ''$.key1'') |\n+-----------------------------------------------------+\n| {"a":1, "b":[1,2]}                                  |\n+-----------------------------------------------------+\n\nSELECT json_query(''{"key1":123, "key1": [1,2,3]}'', ''$.key1'');\n+-------------------------------------------------------+\n| json_query(''{"key1":123, "key1": [1,2,3]}'', ''$.key1'') |\n+-------------------------------------------------------+\n| [1,2,3]                                               |\n+-------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_query', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_query');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (384, 35, 'JSON\\_QUOTE', 'Syntax\n------\n\nJSON_QUOTE(json_value)\n\nDescription\n-----------\n\nQuotes a string as a JSON value, usually for producing valid JSON string literals for inclusion in JSON documents. Wraps the string with double quote characters and escapes interior quotes and other special characters, returning a utf8mb4 string.\n\nReturns NULL if the argument is NULL.\n\nExamples\n--------\n\nSELECT JSON_QUOTE(''A''), JSON_QUOTE("B"), JSON_QUOTE(''"C"'');\n+-----------------+-----------------+-------------------+\n| JSON_QUOTE(''A'') | JSON_QUOTE("B") | JSON_QUOTE(''"C"'') |\n+-----------------+-----------------+-------------------+\n| "A"             | "B"             | "\\"C\\""           |\n+-----------------+-----------------+-------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_quote', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_quote');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (385, 35, 'JSON\\_REMOVE', 'Syntax\n------\n\nJSON_REMOVE(json_doc, path[, path] ...)\n\nDescription\n-----------\n\nRemoves data from a JSON document returning the result, or NULL if any of the arguments are null. If the element does not exist in the document, no changes are made.\n\nThe function returns NULL and throws a warning if the JSON document is invalid, the path is invalid, contains a range, or contains a  or * wildcard.\n\nPath arguments are evaluated from left to right, with the result from the earlier evaluation being used as the value for the next.\n\nExamples\n--------\n\nSELECT JSON_REMOVE(''{"A": 1, "B": 2, "C": {"D": 3}}'', ''$.C'');\n+-------------------------------------------------------+\n| JSON_REMOVE(''{"A": 1, "B": 2, "C": {"D": 3}}'', ''$.C'') |\n+-------------------------------------------------------+\n| {"A": 1, "B": 2}                                      |\n+-------------------------------------------------------+\n\nSELECT JSON_REMOVE(''["A", "B", ["C", "D"], "E"]'', ''$[1]'');\n+----------------------------------------------------+\n| JSON_REMOVE(''["A", "B", ["C", "D"], "E"]'', ''$[1]'') |\n+----------------------------------------------------+\n| ["A", ["C", "D"], "E"]                             |\n+----------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_remove', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_remove');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (386, 35, 'JSON\\_REPLACE', 'Syntax\n------\n\nJSON_REPLACE(json_doc, path, val[, path, val] ...)\n\nDescription\n-----------\n\nReplaces existing values in a JSON document, returning the result, or NULL if any of the arguments are NULL.\n\nAn error will occur if the JSON document is invalid, the path is invalid or if the path contains a  or * wildcard.\n\nPaths and values are evaluated from left to right, with the result from the earlier evaluation being used as the value for the next.\n\nJSON_REPLACE can only update data, while JSON_INSERT can only insert. JSON_SET can update or insert data.\n\nExamples\n--------\n\nSELECT JSON_REPLACE(''{ "A": 1, "B": [2, 3]}'', ''$.B[1]'', 4);\n+-----------------------------------------------------+\n| JSON_REPLACE(''{ "A": 1, "B": [2, 3]}'', ''$.B[1]'', 4) |\n+-----------------------------------------------------+\n| { "A": 1, "B": [2, 4]}                              |\n+-----------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_replace', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_replace');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (387, 35, 'JSON\\_SCHEMA\\_VALID', 'Syntax\n------\n\nJSON_SCHEMA_VALID(schema, json);\n\nDescription\n-----------\n\nJSON_SCHEMA_VALID allows MariaDB to support JSON schema validation. If a given json is valid against a schema it returns true. When JSON does not validate against the schema, it does not return a message about which keyword it failed against and only returns false.\n\nThe function supports JSON Schema Draft 2020 with a few exceptions:\n\n External resources are not supported.\n Hyper schema keywords are not supported.\n Formats like date, email etc are treated as annotations.\n\nExamples\n--------\n\nCREATE TABLE obj_table(val_obj JSON CHECK(JSON_SCHEMA_VALID(''{\n  "type":"object",\n    "properties": {\n      "number1":{\n        "type":"number",\n        "maximum":5,\n        "const":4\n      },\n      "string1":{\n        "type":"string",\n        "maxLength":5,\n        "minLength":3\n      },\n    "object1":{\n      "type":"object",\n       "properties":{\n         "key1": {"type":"string"},\n         "key2":{"type":"array"},\n         "key3":{"type":"number", "minimum":3}\n       },\n       "dependentRequired": { "key1":["key3"] }\n     }\n  },\n  "required":["number1","object1"]\n  }'', val_obj)));\n\nINSERT INTO obj_table VALUES(\n  ''{"number1":4, "string1":"abcd", \n  "object1":{"key1":"val1", "key2":[1,2,3, "string1"], "key3":4}}''\n);\n\nINSERT INTO obj_table VALUES(\n  ''{"number1":3, "string1":"abcd", \n  "object1":{"key1":"val1", "key2":[1,2,3, "string1"], "key3":4}}''\n);\nERROR 4025 (23000): CONSTRAINT obj_table.val_obj failed for test.obj_table\n\nSELECT  FROM obj_table;\n+--------------------------------------------------------------------------------------------------+\n| val_obj                                                                                          |\n+--------------------------------------------------------------------------------------------------+\n| {"number1":4, "string1":"abcd", "object1":{"key1":"val1", "key2":[1,2,3, "string1"], "key3":4}} |\n+--------------------------------------------------------------------------------------------------+\n\nSET @schema= ''{\n  "properties" : {\n    "number1":{ "maximum":10 },\n    "string1" : { "maxLength": 3} \n  }\n}'';\n\nSELECT JSON_SCHEMA_VALID(@schema, ''{ "number1":25, "string1":"ab" }'');\n+----------------------------------------------------------------+\n| JSON_SCHEMA_VALID(@schema, ''{ "number1":25, "string1":"ab" }'') |\n+----------------------------------------------------------------+\n|                                                              0 |\n+----------------------------------------------------------------+\n\nSELECT JSON_SCHEMA_VALID(@schema, ''{ "number1":10, "string1":"ab" }'');\n+----------------------------------------------------------------+\n| JSON_SCHEMA_VALID(@schema, ''{ "number1":10, "string1":"ab" }'') |\n+----------------------------------------------------------------+\n|                                                              1 |\n+----------------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_schema_valid', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_schema_valid');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (388, 35, 'JSON\\_SEARCH', 'Syntax\n------\n\nJSON_SEARCH(json_doc, return_arg, search_str[, escape_char[, path] ...])\n\nDescription\n-----------\n\nReturns the path to the given string within a JSON document, or NULL if any of _json_doc_, _search_str_ or a path argument is NULL; if the search string is not found, or if no path exists within the document.\n\nA warning will occur if the JSON document is not valid, any of the path arguments are not valid, if _return_arg_ is neither _one_ nor _all_, or if the escape character is not a constant. NULL will be returned.\n\n_return_arg_ can be one of two values:\n\n ''one: Terminates after finding the first match, so will return one path string. If there is more than one match, it is undefined which is considered first.\n all: Returns all matching path strings, without duplicates. Multiple strings are autowrapped as an array. The order is undefined.\n\nExamples\n--------\n\nSET @json = ''["A", [{"B": "1"}], {"C":"AB"}, {"D":"BC"}]'';\n\nSELECT JSON_SEARCH(@json, ''one'', ''AB'');\n+---------------------------------+\n| JSON_SEARCH(@json, ''one'', ''AB'') |\n+---------------------------------+\n| "$[2].C"                        |\n+---------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_search', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_search');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (389, 35, 'JSON\\_SET', 'Syntax\n------\n\nJSON_SET(json_doc, path, val[, path, val] ...)\n\nDescription\n-----------\n\nUpdates or inserts data into a JSON document, returning the result, or NULL if any of the arguments are NULL or the optional path fails to find an object.\n\nAn error will occur if the JSON document is invalid, the path is invalid or if the path contains a  or a wildcard\\\\.\\\\*\n\nJSON_SET can update or insert data, while JSON_REPLACE can only update, and JSON_INSERT only insert.\n\nExamples\n--------\n\nSELECT JSON_SET(Priv, ''$.locked'', ''true'') FROM mysql.global_priv\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_set', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_set');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (390, 35, 'JSON\\_TABLE', 'Syntax\n------\n\nJSON_TABLE(json_doc, \n          context_path COLUMNS (column_list)\n) [AS] alias\n\nDescription\n-----------\n\nJSON_TABLE can be used in contexts where a table reference can be used; in the FROM clause of a SELECT statement, and in multi-table UPDATE/DELETE statements.\n\njson_doc is the JSON document to extract data from. In the simplest case, it is a string literal containing JSON. In more complex cases it can be an arbitrary expression returning JSON. The expression may have references to columns of other tables. However, one can only refer to tables that precede this JSON_TABLE invocation. For RIGHT JOIN, it is assumed that its outer side precedes the inner. All tables in outer selects are also considered preceding.\n\ncontext_path is a JSON Path expression pointing to a collection of nodes in json_doc that will be used as the source of rows.\n\nThe COLUMNS clause declares the names and types of the columns that JSON_TABLE returns, as well as how the values of the columns are produced.\n\nColumn Definitions\n\nThe following types of columns are supported:\n\nPath Columns\n\n``sql\nname type PATH path_str [on_empty] [on_error]\n`\n\nLocates the JSON node pointed to by path_str and returns its value. The path_str is evaluated using the current row source node as the context node.\n\n`sql\nSET @json=''\n[\n  {"name":"Laptop", "color":"black", "price":"1000"},\n  {"name":"Jeans",  "color":"blue"}\n]'';\n\nSELECT  FROM json_table(@json, ''$[]'' \n  COLUMNS(\n   name  VARCHAR(10) path ''$.name'', \n   color VARCHAR(10) path ''$.color'',\n   price DECIMAL(8,2) path ''$.price'' ) \n) AS jt;\n+--------+-------+---------+\n| name   | color | price   |\n+--------+-------+---------+\n| Laptop | black | 1000.00 |\n| Jeans  | blue  |    NULL |\n+--------+-------+---------+\n`\n\nThe on_empty and on_error clauses specify the actions to be performed when the value was not found or there was an error condition. See the ON EMPTY and ON ERROR clauses section for details.\n\nORDINALITY Columns\n\n`sql\nname FOR ORDINALITY\n`\n\nCounts the rows, starting from 1.\n\nExample:\n\n`sql\nset @json=''\n[\n  {"name":"Laptop", "color":"black"},\n  {"name":"Jeans",  "color":"blue"}\n]'';\n\nselect  from json_table(@json, ''$[]'' \n  columns(\n   id for ordinality, \n   name  varchar(10) path ''$.name'')\n) as jt;\n+------+--------+\n| id   | name   |\n+------+--------+\n|    1 | Laptop |\n|    2 | Jeans  |\n+------+--------+\n`\n\nEXISTS PATH Columns\n\n`sql\nname type EXISTS PATH path_str\n`\n\nChecks whether the node pointed to by value_path exists. The value_path is evaluated using the current row source node as the context node.\n\n`sql\nset @json=''\n[\n  {"name":"Laptop", "color":"black", "price":1000},\n  {"name":"Jeans",  "color":"blue"}\n]'';\n\nselect  from json_table(@json, ''$[]'' \n  columns(\n   name  varchar(10) path ''$.name'',\n   has_price integer exists path ''$.price'')\n) as jt;\n+--------+-----------+\n| name   | has_price |\n+--------+-----------+\n| Laptop |         1 |\n| Jeans  |         0 |\n+--------+-----------+\n`\n\nNESTED PATHs\n\nNESTED PATH converts nested JSON structures into multiple rows.\n\n`sql\nNESTED PATH path COLUMNS (column_list)\n`\n\nIt finds the sequence of JSON nodes pointed to by path and uses it to produce rows. For each found node, a row is generated with column values as specified by the NESTED PATH''s COLUMNS clause. If path finds no nodes, only one row is generated with all columns having NULL values.\n\nFor example, consider a JSON document that contains an array of items, and each item, in turn, is expected to have an array of its available sizes:\n\n`json\nSET @json=''\n[\n  {"name":"Jeans",  "sizes": [32, 34, 36]},\n  {"name":"T-Shirt", "sizes":["Medium", "Large"]},\n  {"name":"Cellphone"}\n]'';\n`\n\nNESTED PATH allows one to produce a separate row for each size each item has:\n\n`sql\nselect  from json_table(@json, ''$[]'' \n  columns(\n    name  varchar(10) path ''$.name'', \n    nested path ''$.sizes[]'' columns (\n      size varchar(32) path ''$''\n    )\n  )\n) as jt;\n+-----------+--------+\n| name      | size   |\n+-----------+--------+\n| Jeans     | 32     |\n| Jeans     | 34     |\n| Jeans     | 36     |\n| T-Shirt   | Medium |\n| T-Shirt   | Large  |\n| Cellphone | NULL   |\n+-----------+--------+\n`\n\nNESTED PATH clauses can be nested within one another. They can also be located next to each other. In that case, the nested path clauses will produce records one at a time. The ones that are not producing records will have all columns set to NULL.\n\nExample:\n\n`sql\nset @json=''\n[\n  {"name":"Jeans",  "sizes": [32, 34, 36], "colors":["black", "blue"]}\n]'';\n\nselect  from json_table(@json, ''$[]'' \n  columns(\n    name  varchar(10) path ''$.name'', \n    nested path ''$.sizes[]'' columns (\n      size varchar(32) path ''$''\n    ),\n    nested path ''$.colors[]'' columns (\n      color varchar(32) path ''$''\n    )\n  )\n) as jt;\n\n+-------+------+-------+\n| name  | size | color |\n+-------+------+-------+\n| Jeans | 32   | NULL  |\n| Jeans | 34   | NULL  |\n| Jeans | 36   | NULL  |\n| Jeans | NULL | black |\n| Jeans | NULL | blue  |\n+-------+------+-------+\n`\n\nON EMPTY and ON ERROR Clauses\n\nThe ON EMPTY clause specifies what will be done when the element specified by the search path is missing in the JSON document.\n\n`sql\non_empty:\n    {NULL | DEFAULT string | ERROR} ON EMPTY\n`\n\nWhen ON EMPTY clause is not present, NULL ON EMPTY is implied.\n\n`sql\non_error:\n    {NULL | DEFAULT string | ERROR} ON ERROR\n`\n\nThe ON ERROR clause specifies what should be done if a JSON structure error occurs when trying to extract the value pointed to by the path expression. A JSON structure error here occurs only when one attempts to convert a JSON non-scalar (array or object) into a scalar value. When the ON ERROR clause is not present, NULL ON ERROR is implied.\n\nNote: A datatype conversion error (e.g. attempt to store a non-integer value into an integer field, or a varchar column being truncated) is not considered a JSON error and so will not trigger the ON ERROR behavior. It will produce warnings, in the same way as CAST(value AS datatype) would.\n\nReplication\n\nIn the current code, evaluation of JSON_TABLE is deterministic, that is, for a given input string JSON_TABLE will always produce the same set of rows in the same order. However, one can think of JSON documents that one can consider identical which will produce different output. In order to be future-proof and withstand changes like\n\n sorting JSON object members by name (like MySQL does);\n changing the way duplicate object members are handled the function is marked as unsafe for statement-based replication.\n\nExtracting a Subdocument into a Column\n\n`sql\nSELECT  FROM JSON_TABLE(''{"foo": [1,2,3,4]}'',''$'' columns( jscol json path ''$.foo'') ) AS T;\n+-----------+\n| jscol     |\n+-----------+\n| [1,2,3,4] |\n+-----------+\n`\n\nJSON_TABLE does not allow to extract a JSON "subdocument" into a JSON column.\n\n`sql\nSELECT * FROM JSON_TABLE(''{"foo": [1,2,3,4]}'',''$'' columns( jscol json path ''$.foo'') ) AS T;\n+-------+\n| jscol |\n+-------+\n| NULL  |\n+-------+\n``\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_table', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_table');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (391, 35, 'JSON\\_TYPE', 'Syntax\n------\n\nJSON_TYPE(json_val)\n\nDescription\n-----------\n\nReturns the type of a JSON value (as a string), or NULL if the argument is null.\n\nAn error will occur if the argument is an invalid JSON value.\n\nThe following is a complete list of the possible return types:\n\n| Return type | Value                                                                                         | Example                   |\n| ----------- | --------------------------------------------------------------------------------------------- | ------------------------- |\n| ARRAY       | JSON array                                                                                    | \\[1, 2, {"key": "value"}] |\n| OBJECT      | JSON object                                                                                   | {"key":"value"}           |\n| BOOLEAN     | JSON true/false literals                                                                      | true, false               |\n| DOUBLE      | A number with at least one floating point decimal.                                            | 1.2                       |\n| INTEGER     | A number without a floating point decimal.                                                    | 1                         |\n| NULL        | JSON null literal (this is returned as a string, not to be confused with the SQL NULL value!) | null                      |\n| STRING      | JSON String                                                                                   | "a sample string"         |\n\nExamples\n--------\n\nSELECT JSON_TYPE(''{"A": 1, "B": 2, "C": 3}'');\n+---------------------------------------+\n| JSON_TYPE(''{"A": 1, "B": 2, "C": 3}'') |\n+---------------------------------------+\n| OBJECT                                |\n+---------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_type', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_type');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (392, 35, 'JSON\\_UNQUOTE', 'Syntax\n------\n\nJSON_UNQUOTE(val)\n\nDescription\n-----------\n\nUnquotes a JSON value, returning a string, or NULL if the argument is null.\n\nAn error will occur if the given value begins and ends with double quotes and is an invalid JSON string literal.\n\nIf the given value is not a JSON string, value is passed through unmodified.\n\nCertain character sequences have special meanings within a string. Usually, a backslash is ignored, but the escape sequences in the table below are recognised by MariaDB, unless the SQL Mode is set to NO_BACKSLASH_ESCAPES .\n\n| Escape sequence | Character                          |\n| --------------- | ---------------------------------- |\n| "               | Double quote (")                   |\n| \\b              | Backslash                          |\n| \\f              | Formfeed                           |\n| \\n              | Newline (linefeed)                 |\n| \\r              | Carriage return                    |\n| \\t              | Tab                                |\n| \\\\              | Backslash ()                       |\n| \\uXXXX          | UTF-8 bytes for Unicode value XXXX |\n\nExamples\n--------\n\nSELECT JSON_UNQUOTE(''"Monty"'');\n+-------------------------+\n| JSON_UNQUOTE(''"Monty"'') |\n+-------------------------+\n| Monty                   |\n+-------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_unquote', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_unquote');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (393, 35, 'JSON\\_VALID', 'Syntax\n------\n\nJSON_VALID(value)\n\nDescription\n-----------\n\nIndicates whether the given value is a valid JSON document or not. Returns 1 if valid, 0 if not, and NULL if the argument is NULL.\n\nThe JSON_VALID function is automatically used as a CHECK constraint for the JSON data type alias in order to ensure that a valid json document is inserted.\n\nThe JSON_VALID function is not automatically used as a CHECK constraint for the JSON data type alias.\n\nExamples\n--------\n\nSELECT JSON_VALID(''{"id": 1, "name": "Monty"}'');\n+------------------------------------------+\n| JSON_VALID(''{"id": 1, "name": "Monty"}'') |\n+------------------------------------------+\n|                                        1 |\n+------------------------------------------+\n\nSELECT JSON_VALID(''{"id": 1, "name": "Monty", "oddfield"}'');\n+------------------------------------------------------+\n| JSON_VALID(''{"id": 1, "name": "Monty", "oddfield"}'') |\n+------------------------------------------------------+\n|                                                    0 |\n+------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_valid', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_valid');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (394, 35, 'JSON\\_VALUE', 'Syntax\n------\n\nJSON_VALUE(json_doc, path)\n\nDescription\n-----------\n\nGiven a JSON document, returns the scalar specified by the path. Returns NULL if not given a valid JSON document, or if there is no match.\n\nExamples\n--------\n\nSELECT json_value(''{"key1":123}'', ''$.key1'');\n+--------------------------------------+\n| json_value(''{"key1":123}'', ''$.key1'') |\n+--------------------------------------+\n| 123                                  |\n+--------------------------------------+\n\nSELECT json_value(''{"key1": [1,2,3], "key1":123}'', ''$.key1'');\n+-------------------------------------------------------+\n| json_value(''{"key1": [1,2,3], "key1":123}'', ''$.key1'') |\n+-------------------------------------------------------+\n| 123                                                   |\n+-------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_value', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_value');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (395, 35, 'JSONPath Expressions', 'Description\n-----------\n\nA number of JSON functions accept JSON Path expressions. MariaDB defines this path as follows:\n\nJSON Path Syntax\n\n``sql\npath : [''lax''] ''$'' [step]\n`\n\nThe path starts with an optional _path mode_. At the moment, MariaDB supports only the "lax" mode, which is also the mode that is used when it is not explicitly specified.\n\nThe $ symbol represents the context item. The search always starts from the context item; because of that, the path always starts with $.\n\nThen, it is followed by zero or more steps, which select element(s) in the JSON document. A step may be one of the following:\n\n Object member selector.\n Array element selector.\n Wildcard selector.\n\nObject Member Selector\n\nTo select member(s) in a JSON object, one can use one of the following:\n\n .memberName selects the value of the member with name memberName.\n ."memberName" - the same as above but allows one to select a member with a name that''s not a valid identifier (that is, has space, dot, and/or other characters).\n . - selects the values of all members of the object.\n\nIf the current item is an array (instead of an object), nothing will be selected.\n\nArray Element Selector\n\nTo select elements of an array, one can use one of the following:\n\n [N] selects element number N in the array. The elements are counted from zero.\n [] selects all elements in the array.\n\nIf the current item is an object (instead of an array), nothing will be selected.\n\nJSON path supports negative indexes in an array, ''last'' keyword and range notation (''to'' keyword) for accessing array elements. Negative indexes start from -1.\n\n [-N] selects n th element from end.\n [last-N] selects n th element from the last element.\n [M to N] selects range of elements starting from index M to N.\n\nExample:\n\n`sql\nSET @json=''{\n            "A": [0,\n                  [1, 2, 3],\n                  [4, 5, 6],\n                  "seven",\n                   0.8,\n                   true,\n                   false,\n                   "eleven",\n                  [12, [13, 14], {"key1":"value1"},[15]],\n                  true],\n            "B": {"C": 1},\n            "D": 2\n           }'';\nSELECT JSON_EXTRACT(@json, ''$.A[-8][1]'');\n+--------------------------------------------------+\n| JSON_EXTRACT(@json, ''$.A[-8][1]'')                |\n+--------------------------------------------------+\n| 5                                                |\n+--------------------------------------------------+\n\nSELECT JSON_EXTRACT(@json, ''$.A[last-7][1]'');\n+-----------------------------------------------+\n| SELECT JSON_EXTRACT(@json, ''$.A[last-7][1]''); |\n+-----------------------------------------------+\n| 5                                             |\n+-----------------------------------------------+\n\nSET @json= ''[\n             [1, {"key1": "value1"}, 3],\n             [false, 5, 6],\n             [7, 8, [9, {"key2": 2}, 11]],\n             [15, 1.34, [14], ["string1", [16, {"key1":[1,2,3,[4,5,6]]}, 18]]],\n             [19, 20],\n             21, 22\n            ]'';\n\nSELECT JSON_EXTRACT(@json, ''$[0 to 3][2]'');\n+-----------------------------------------------+\n| JSON_EXTRACT(@json, ''$[0 to 3][2]'')           |\n+-----------------------------------------------+\n| [3, 6, [9, {"key2": 2}, 11], [14]]            |\n+-----------------------------------------------+\n`\n\nJSON path does not support negative indexes in an array.\n\nThis produces output for first index of eighth from last element of a two dimensional array.\n\nNote: In range notation, when M > N ( when M,N are greater than or equal to 0) or (size of array - M or size of array - N when M, N are less than 0), then it is treated as an impossible range and NULL is returned.\n\n`sql\nSET @json= ''[1, 2, 3, 4, 5]'';\nSELECT JSON_EXTRACT(@json, ''$[4 to 2]'');\n+-----------------------------------+\n| JSON_EXTRACT(@json, ''$[4 to 2]'')  |\n+-----------------------------------+\n| NULL                              |\n+-----------------------------------+\n`\n\nWildcard\n\nThe wildcard step, , recursively selects all child elements of the current element. Both array elements and object members are selected.\n\nThe wildcard step must not be the last step in the JSONPath expression. It must be followed by an array or object member selector step.\n\nFor example, this query selects all object members named price in the document:\n\n`sql\nSELECT json_extract(@json_doc, ''$.price'');\n`\n\nThis query, however, selects the second element in each of the arrays present in the document:\n\n`sql\nSELECT json_extract(@json_doc, ''$[2]'');\n`\n\nCompatibility\n\nMariaDB''s JSONPath syntax supports a subset of JSON Path''s definition in the SQL Standard. The most notable things not supported are the strict mode and filters.\n\nMariaDB''s JSONPath is close to MySQL''s JSONPath. The wildcard step (  ) is a non-standard extension that has the same meaning as in MySQL. The difference between MariaDB and MySQL''s JSONPath is: MySQL doesn''t allow one to specify the mode explicitly (but uses lax` mode implicitly).\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/jsonpath-expressions', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/jsonpath-expressions');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (396, 35, 'CUME\\_DIST', 'Syntax\n------\n\nCUME_DIST() OVER ( \n  [ PARTITION BY partition_expression ] \n  [ ORDER BY order_list ]\n)\n\nDescription\n-----------\n\nCUME_DIST() is a window function that returns the cumulative distribution of a given row. The following formula is used to calculate the value:\n\n``sql\n(number of rows <= current row) / (total rows)\n``\n\nExamples\n--------\n\ncreate table t1 (\n  pk int primary key,\n  a int,\n  b int\n);\n\ninsert into t1 values\n( 1 , 0, 10),\n( 2 , 0, 10),\n( 3 , 1, 10),\n( 4 , 1, 10),\n( 8 , 2, 10),\n( 5 , 2, 20),\n( 6 , 2, 20),\n( 7 , 2, 20),\n( 9 , 4, 20),\n(10 , 4, 20);\n\nselect pk, a, b,\n    rank() over (order by a) as rank,\n    percent_rank() over (order by a) as pct_rank,\n    cume_dist() over (order by a) as cume_dist\nfrom t1;\n+----+------+------+------+--------------+--------------+\n| pk | a    | b    | rank | pct_rank     | cume_dist    |\n+----+------+------+------+--------------+--------------+\n|  1 |    0 |   10 |    1 | 0.0000000000 | 0.2000000000 |\n|  2 |    0 |   10 |    1 | 0.0000000000 | 0.2000000000 |\n|  3 |    1 |   10 |    3 | 0.2222222222 | 0.4000000000 |\n|  4 |    1 |   10 |    3 | 0.2222222222 | 0.4000000000 |\n|  5 |    2 |   20 |    5 | 0.4444444444 | 0.8000000000 |\n|  6 |    2 |   20 |    5 | 0.4444444444 | 0.8000000000 |\n|  7 |    2 |   20 |    5 | 0.4444444444 | 0.8000000000 |\n|  8 |    2 |   10 |    5 | 0.4444444444 | 0.8000000000 |\n|  9 |    4 |   20 |    9 | 0.8888888889 | 1.0000000000 |\n| 10 |    4 |   20 |    9 | 0.8888888889 | 1.0000000000 |\n+----+------+------+------+--------------+--------------+\n\nselect pk, a, b,\n       percent_rank() over (order by pk) as pct_rank,\n       cume_dist() over (order by pk) as cume_dist\nfrom t1 order by pk;\n+----+------+------+--------------+--------------+\n| pk | a    | b    | pct_rank     | cume_dist    |\n+----+------+------+--------------+--------------+\n|  1 |    0 |   10 | 0.0000000000 | 0.1000000000 |\n|  2 |    0 |   10 | 0.1111111111 | 0.2000000000 |\n|  3 |    1 |   10 | 0.2222222222 | 0.3000000000 |\n|  4 |    1 |   10 | 0.3333333333 | 0.4000000000 |\n|  5 |    2 |   20 | 0.4444444444 | 0.5000000000 |\n|  6 |    2 |   20 | 0.5555555556 | 0.6000000000 |\n|  7 |    2 |   20 | 0.6666666667 | 0.7000000000 |\n|  8 |    2 |   10 | 0.7777777778 | 0.8000000000 |\n|  9 |    4 |   20 | 0.8888888889 | 0.9000000000 |\n| 10 |    4 |   20 | 1.0000000000 | 1.0000000000 |\n+----+------+------+--------------+--------------+\n\nselect pk, a, b,\n        percent_rank() over (partition by a order by a) as pct_rank,\n        cume_dist() over (partition by a order by a) as cume_dist\nfrom t1;\n+----+------+------+--------------+--------------+\n| pk | a    | b    | pct_rank     | cume_dist    |\n+----+------+------+--------------+--------------+\n|  1 |    0 |   10 | 0.0000000000 | 1.0000000000 |\n|  2 |    0 |   10 | 0.0000000000 | 1.0000000000 |\n|  3 |    1 |   10 | 0.0000000000 | 1.0000000000 |\n|  4 |    1 |   10 | 0.0000000000 | 1.0000000000 |\n|  5 |    2 |   20 | 0.0000000000 | 1.0000000000 |\n|  6 |    2 |   20 | 0.0000000000 | 1.0000000000 |\n|  7 |    2 |   20 | 0.0000000000 | 1.0000000000 |\n|  8 |    2 |   10 | 0.0000000000 | 1.0000000000 |\n|  9 |    4 |   20 | 0.0000000000 | 1.0000000000 |\n| 10 |    4 |   20 | 0.0000000000 | 1.0000000000 |\n+----+------+------+--------------+--------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/cume_dist', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/cume_dist');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (397, 35, 'DENSE\\_RANK', 'Syntax\n------\n\nDENSE_RANK() OVER (\n  [ PARTITION BY partition_expression ]\n  [ ORDER BY order_list ]\n)\n\nDescription\n-----------\n\nDENSE_RANK() is a window function that displays the number of a given row, starting at one and following the ORDER BY sequence of the window function, with identical values receiving the same result. Unlike the RANK() function, there are no skipped values if the preceding results are identical. It is also similar to the ROW_NUMBER() function except that in that function, identical values will receive a different row number for each result.\n\nExamples\n--------\n\nCREATE TABLE student(course VARCHAR(10), mark int, name varchar(10));\n\nINSERT INTO student VALUES \n  (''Maths'', 60, ''Thulile''),\n  (''Maths'', 60, ''Pritha''),\n  (''Maths'', 70, ''Voitto''),\n  (''Maths'', 55, ''Chun''),\n  (''Biology'', 60, ''Bilal''),\n   (''Biology'', 70, ''Roger'');\n\nSELECT \n  RANK() OVER (PARTITION BY course ORDER BY mark DESC) AS rank, \n  DENSE_RANK() OVER (PARTITION BY course ORDER BY mark DESC) AS dense_rank, \n  ROW_NUMBER() OVER (PARTITION BY course ORDER BY mark DESC) AS row_num, \n  course, mark, name \nFROM student ORDER BY course, mark DESC;\n+------+------------+---------+---------+------+---------+\n| rank | dense_rank | row_num | course  | mark | name    |\n+------+------------+---------+---------+------+---------+\n|    1 |          1 |       1 | Biology |   70 | Roger   |\n|    2 |          2 |       2 | Biology |   60 | Bilal   |\n|    1 |          1 |       1 | Maths   |   70 | Voitto  |\n|    2 |          2 |       2 | Maths   |   60 | Thulile |\n|    2 |          2 |       3 | Maths   |   60 | Pritha  |\n|    4 |          3 |       4 | Maths   |   55 | Chun    |\n+------+------------+---------+---------+------+---------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/dense_rank', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/dense_rank');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (398, 35, 'FIRST\\_VALUE', 'Syntax\n------\n\nFIRST_VALUE(expr) OVER (\n  [ PARTITION BY partition_expression ]\n  [ ORDER BY order_list ]\n)\n\nDescription\n-----------\n\nFIRST_VALUE returns the first result from an ordered set, or NULL if no such result exists.\n\nExamples\n--------\n\nCREATE TABLE t1 (\n  pk int primary key,\n  a int,\n  b int,\n  c char(10),\n  d decimal(10, 3),\n  e real\n);\n\nINSERT INTO t1 VALUES\n( 1, 0, 1,    ''one'',    0.1,  0.001),\n( 2, 0, 2,    ''two'',    0.2,  0.002),\n( 3, 0, 3,    ''three'',  0.3,  0.003),\n( 4, 1, 2,    ''three'',  0.4,  0.004),\n( 5, 1, 1,    ''two'',    0.5,  0.005),\n( 6, 1, 1,    ''one'',    0.6,  0.006),\n( 7, 2, NULL, ''n_one'',  0.5,  0.007),\n( 8, 2, 1,    ''n_two'',  NULL, 0.008),\n( 9, 2, 2,    NULL,     0.7,  0.009),\n(10, 2, 0,    ''n_four'', 0.8,  0.010),\n(11, 2, 10,   NULL,     0.9,  NULL);\n\nSELECT pk, FIRST_VALUE(pk) OVER (ORDER BY pk) AS first_asc,\n           LAST_VALUE(pk) OVER (ORDER BY pk) AS last_asc,\n           FIRST_VALUE(pk) OVER (ORDER BY pk DESC) AS first_desc,\n           LAST_VALUE(pk) OVER (ORDER BY pk DESC) AS last_desc\nFROM t1\nORDER BY pk DESC;\n\n+----+-----------+----------+------------+-----------+\n| pk | first_asc | last_asc | first_desc | last_desc |\n+----+-----------+----------+------------+-----------+\n| 11 |         1 |       11 |         11 |        11 |\n| 10 |         1 |       10 |         11 |        10 |\n|  9 |         1 |        9 |         11 |         9 |\n|  8 |         1 |        8 |         11 |         8 |\n|  7 |         1 |        7 |         11 |         7 |\n|  6 |         1 |        6 |         11 |         6 |\n|  5 |         1 |        5 |         11 |         5 |\n|  4 |         1 |        4 |         11 |         4 |\n|  3 |         1 |        3 |         11 |         3 |\n|  2 |         1 |        2 |         11 |         2 |\n|  1 |         1 |        1 |         11 |         1 |\n+----+-----------+----------+------------+-----------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/first_value', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/first_value');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (399, 35, 'LAG', 'Syntax\n------\n\nLAG (expr[, offset]) OVER ( \n  [ PARTITION BY partition_expression ] \n  < ORDER BY order_list >\n)\n\nDescription\n-----------\n\nThe LAG function accesses data from a previous row according to the ORDER BY clause without the need for a self-join. The specific row is determined by the _offset_ (default _1_), which specifies the number of rows behind the current row to use. An offset of _0_ is the current row.\n\nExamples\n--------\n\nCREATE TABLE t1 (pk int primary key, a int, b int, c char(10), d decimal(10, 3), e real);\n\nINSERT INTO t1 VALUES\n ( 1, 0, 1,    ''one'',    0.1,  0.001),\n ( 2, 0, 2,    ''two'',    0.2,  0.002),\n ( 3, 0, 3,    ''three'',  0.3,  0.003),\n ( 4, 1, 2,    ''three'',  0.4,  0.004),\n ( 5, 1, 1,    ''two'',    0.5,  0.005),\n ( 6, 1, 1,    ''one'',    0.6,  0.006),\n ( 7, 2, NULL, ''n_one'',  0.5,  0.007),\n ( 8, 2, 1,    ''n_two'',  NULL, 0.008),\n ( 9, 2, 2,    NULL,     0.7,  0.009),\n (10, 2, 0,    ''n_four'', 0.8,  0.010),\n (11, 2, 10,   NULL,     0.9,  NULL);\n\nSELECT pk, LAG(pk) OVER (ORDER BY pk) AS l,\n  LAG(pk,1) OVER (ORDER BY pk) AS l1,\n  LAG(pk,2) OVER (ORDER BY pk) AS l2,\n  LAG(pk,0) OVER (ORDER BY pk) AS l0,\n  LAG(pk,-1) OVER (ORDER BY pk) AS lm1,\n  LAG(pk,-2) OVER (ORDER BY pk) AS lm2 \nFROM t1;\n+----+------+------+------+------+------+------+\n| pk | l    | l1   | l2   | l0   | lm1  | lm2  |\n+----+------+------+------+------+------+------+\n|  1 | NULL | NULL | NULL |    1 |    2 |    3 |\n|  2 |    1 |    1 | NULL |    2 |    3 |    4 |\n|  3 |    2 |    2 |    1 |    3 |    4 |    5 |\n|  4 |    3 |    3 |    2 |    4 |    5 |    6 |\n|  5 |    4 |    4 |    3 |    5 |    6 |    7 |\n|  6 |    5 |    5 |    4 |    6 |    7 |    8 |\n|  7 |    6 |    6 |    5 |    7 |    8 |    9 |\n|  8 |    7 |    7 |    6 |    8 |    9 |   10 |\n|  9 |    8 |    8 |    7 |    9 |   10 |   11 |\n| 10 |    9 |    9 |    8 |   10 |   11 | NULL |\n| 11 |   10 |   10 |    9 |   11 | NULL | NULL |\n+----+------+------+------+------+------+------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/lag', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/lag');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (400, 35, 'LEAD', 'Syntax\n------\n\nLEAD (expr[, offset]) OVER ( \n  [ PARTITION BY partition_expression ] \n  [ ORDER BY order_list ]\n)\n\nDescription\n-----------\n\nThe LEAD function accesses data from a following row in the same result set without the need for a self-join. The specific row is determined by the _offset_ (default _1_), which specifies the number of rows ahead the current row to use. An offset of _0_ is the current row.\n\nExamples\n--------\n\nCREATE TABLE t1 (pk int primary key, a int, b int, c char(10), d decimal(10, 3), e real);\n\nINSERT INTO t1 VALUES\n ( 1, 0, 1,    ''one'',    0.1,  0.001),\n ( 2, 0, 2,    ''two'',    0.2,  0.002),\n ( 3, 0, 3,    ''three'',  0.3,  0.003),\n ( 4, 1, 2,    ''three'',  0.4,  0.004),\n ( 5, 1, 1,    ''two'',    0.5,  0.005),\n ( 6, 1, 1,    ''one'',    0.6,  0.006),\n ( 7, 2, NULL, ''n_one'',  0.5,  0.007),\n ( 8, 2, 1,    ''n_two'',  NULL, 0.008),\n ( 9, 2, 2,    NULL,     0.7,  0.009),\n (10, 2, 0,    ''n_four'', 0.8,  0.010),\n (11, 2, 10,   NULL,     0.9,  NULL);\n\nSELECT pk, LEAD(pk) OVER (ORDER BY pk) AS l,\n  LEAD(pk,1) OVER (ORDER BY pk) AS l1,\n  LEAD(pk,2) OVER (ORDER BY pk) AS l2,\n  LEAD(pk,0) OVER (ORDER BY pk) AS l0,\n  LEAD(pk,-1) OVER (ORDER BY pk) AS lm1,\n  LEAD(pk,-2) OVER (ORDER BY pk) AS lm2 \nFROM t1;\n+----+------+------+------+------+------+------+\n| pk | l    | l1   | l2   | l0   | lm1  | lm2  |\n+----+------+------+------+------+------+------+\n|  1 |    2 |    2 |    3 |    1 | NULL | NULL |\n|  2 |    3 |    3 |    4 |    2 |    1 | NULL |\n|  3 |    4 |    4 |    5 |    3 |    2 |    1 |\n|  4 |    5 |    5 |    6 |    4 |    3 |    2 |\n|  5 |    6 |    6 |    7 |    5 |    4 |    3 |\n|  6 |    7 |    7 |    8 |    6 |    5 |    4 |\n|  7 |    8 |    8 |    9 |    7 |    6 |    5 |\n|  8 |    9 |    9 |   10 |    8 |    7 |    6 |\n|  9 |   10 |   10 |   11 |    9 |    8 |    7 |\n| 10 |   11 |   11 | NULL |   10 |    9 |    8 |\n| 11 | NULL | NULL | NULL |   11 |   10 |    9 |\n+----+------+------+------+------+------+------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/lead', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/lead');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (401, 35, 'MEDIAN', 'Syntax\n------\n\nMEDIAN(median expression) OVER (\n  [ PARTITION BY partition_expression ] \n)\n\nDescription\n-----------\n\nMEDIAN() is a window function that returns the median value of a range of values.\n\nIt is a specific case of PERCENTILE_CONT, with an argument of 0.5 and the ORDER BY column the one in MEDIAN''s argument.\n\n``sql\nMEDIAN(<median-arg>) OVER ( [ PARTITION BY partition_expression] )\n`\n\nIs equivalent to:\n\n`sql\nPERCENTILE_CONT(0.5) WITHIN \n  GROUP (ORDER BY <median-arg>) OVER ( [ PARTITION BY partition_expression ])\n``\n\nExamples\n--------\n\nCREATE TABLE book_rating (name CHAR(30), star_rating TINYINT);\n\nINSERT INTO book_rating VALUES (''Lord of the Ladybirds'', 5);\nINSERT INTO book_rating VALUES (''Lord of the Ladybirds'', 3);\nINSERT INTO book_rating VALUES (''Lady of the Flies'', 1);\nINSERT INTO book_rating VALUES (''Lady of the Flies'', 2);\nINSERT INTO book_rating VALUES (''Lady of the Flies'', 5);\n\nSELECT name, median(star_rating) OVER (PARTITION BY name) FROM book_rating;\n+-----------------------+----------------------------------------------+\n| name                  | median(star_rating) OVER (PARTITION BY name) |\n+-----------------------+----------------------------------------------+\n| Lord of the Ladybirds |                                 4.0000000000 |\n| Lord of the Ladybirds |                                 4.0000000000 |\n| Lady of the Flies     |                                 2.0000000000 |\n| Lady of the Flies     |                                 2.0000000000 |\n| Lady of the Flies     |                                 2.0000000000 |\n+-----------------------+----------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/median', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/median');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (402, 35, 'NTH\\_VALUE', 'Syntax\n------\n\nNTH_VALUE (expr[, num_row]) OVER ( \n  [ PARTITION BY partition_expression ] \n  [ ORDER BY order_list ]\n)\n\nDescription\n-----------\n\nThe NTH_VALUE function returns the value evaluated at row number num_row of the window frame, starting from 1, or NULL if the row does not exist.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/nth_value', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/nth_value');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (403, 35, 'NTILE', 'Syntax\n------\n\nNTILE (expr) OVER ( \n  [ PARTITION BY partition_expression ] \n  [ ORDER BY order_list ]\n)\n\nDescription\n-----------\n\nNTILE() is a window function that returns an integer indicating which group a given row falls into. The number of groups is specified in the argument (_expr_), starting at one. Ordered rows in the partition are divided into the specified number of groups with as equal a size as possible.\n\nExamples\n--------\n\ncreate table t1 (\n    pk int primary key,\n    a int,\n    b int\n  );\n\ninsert into t1 values\n    (11 , 0, 10),\n    (12 , 0, 10),\n    (13 , 1, 10),\n    (14 , 1, 10),\n    (18 , 2, 10),\n    (15 , 2, 20),\n    (16 , 2, 20),\n    (17 , 2, 20),\n    (19 , 4, 20),\n    (20 , 4, 20);\n\nselect pk, a, b,\n    ntile(1) over (order by pk)\n  from t1;\n+----+------+------+-----------------------------+\n| pk | a    | b    | ntile(1) over (order by pk) |\n+----+------+------+-----------------------------+\n| 11 |    0 |   10 |                           1 |\n| 12 |    0 |   10 |                           1 |\n| 13 |    1 |   10 |                           1 |\n| 14 |    1 |   10 |                           1 |\n| 15 |    2 |   20 |                           1 |\n| 16 |    2 |   20 |                           1 |\n| 17 |    2 |   20 |                           1 |\n| 18 |    2 |   10 |                           1 |\n| 19 |    4 |   20 |                           1 |\n| 20 |    4 |   20 |                           1 |\n+----+------+------+-----------------------------+\n\nselect pk, a, b,\n    ntile(4) over (order by pk)\n from t1;\n+----+------+------+-----------------------------+\n| pk | a    | b    | ntile(4) over (order by pk) |\n+----+------+------+-----------------------------+\n| 11 |    0 |   10 |                           1 |\n| 12 |    0 |   10 |                           1 |\n| 13 |    1 |   10 |                           1 |\n| 14 |    1 |   10 |                           2 |\n| 15 |    2 |   20 |                           2 |\n| 16 |    2 |   20 |                           2 |\n| 17 |    2 |   20 |                           3 |\n| 18 |    2 |   10 |                           3 |\n| 19 |    4 |   20 |                           4 |\n| 20 |    4 |   20 |                           4 |\n+----+------+------+-----------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/ntile', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/ntile');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (404, 35, 'PERCENT\\_RANK', 'Syntax\n------\n\nPERCENT_RANK() OVER (\n  [ PARTITION BY partition_expression ] \n  [ ORDER BY order_list ]\n)\n\nDescription\n-----------\n\nPERCENT_RANK() is a window function that returns the relative percent rank of a given row. The following formula is used to calculate the percent rank:\n\n``sql\n(rank - 1) / (number of rows in the window or partition - 1)\n``\n\nExamples\n--------\n\ncreate table t1 (\n  pk int primary key,\n  a int,\n  b int\n);\n\ninsert into t1 values\n( 1 , 0, 10),\n( 2 , 0, 10),\n( 3 , 1, 10),\n( 4 , 1, 10),\n( 8 , 2, 10),\n( 5 , 2, 20),\n( 6 , 2, 20),\n( 7 , 2, 20),\n( 9 , 4, 20),\n(10 , 4, 20);\n\nselect pk, a, b,\n    rank() over (order by a) as rank,\n    percent_rank() over (order by a) as pct_rank,\n    cume_dist() over (order by a) as cume_dist\nfrom t1;\n+----+------+------+------+--------------+--------------+\n| pk | a    | b    | rank | pct_rank     | cume_dist    |\n+----+------+------+------+--------------+--------------+\n|  1 |    0 |   10 |    1 | 0.0000000000 | 0.2000000000 |\n|  2 |    0 |   10 |    1 | 0.0000000000 | 0.2000000000 |\n|  3 |    1 |   10 |    3 | 0.2222222222 | 0.4000000000 |\n|  4 |    1 |   10 |    3 | 0.2222222222 | 0.4000000000 |\n|  5 |    2 |   20 |    5 | 0.4444444444 | 0.8000000000 |\n|  6 |    2 |   20 |    5 | 0.4444444444 | 0.8000000000 |\n|  7 |    2 |   20 |    5 | 0.4444444444 | 0.8000000000 |\n|  8 |    2 |   10 |    5 | 0.4444444444 | 0.8000000000 |\n|  9 |    4 |   20 |    9 | 0.8888888889 | 1.0000000000 |\n| 10 |    4 |   20 |    9 | 0.8888888889 | 1.0000000000 |\n+----+------+------+------+--------------+--------------+\n\nselect pk, a, b,\n       percent_rank() over (order by pk) as pct_rank,\n       cume_dist() over (order by pk) as cume_dist\nfrom t1 order by pk;\n+----+------+------+--------------+--------------+\n| pk | a    | b    | pct_rank     | cume_dist    |\n+----+------+------+--------------+--------------+\n|  1 |    0 |   10 | 0.0000000000 | 0.1000000000 |\n|  2 |    0 |   10 | 0.1111111111 | 0.2000000000 |\n|  3 |    1 |   10 | 0.2222222222 | 0.3000000000 |\n|  4 |    1 |   10 | 0.3333333333 | 0.4000000000 |\n|  5 |    2 |   20 | 0.4444444444 | 0.5000000000 |\n|  6 |    2 |   20 | 0.5555555556 | 0.6000000000 |\n|  7 |    2 |   20 | 0.6666666667 | 0.7000000000 |\n|  8 |    2 |   10 | 0.7777777778 | 0.8000000000 |\n|  9 |    4 |   20 | 0.8888888889 | 0.9000000000 |\n| 10 |    4 |   20 | 1.0000000000 | 1.0000000000 |\n+----+------+------+--------------+--------------+\n\nselect pk, a, b,\n        percent_rank() over (partition by a order by a) as pct_rank,\n        cume_dist() over (partition by a order by a) as cume_dist\nfrom t1;\n+----+------+------+--------------+--------------+\n| pk | a    | b    | pct_rank     | cume_dist    |\n+----+------+------+--------------+--------------+\n|  1 |    0 |   10 | 0.0000000000 | 1.0000000000 |\n|  2 |    0 |   10 | 0.0000000000 | 1.0000000000 |\n|  3 |    1 |   10 | 0.0000000000 | 1.0000000000 |\n|  4 |    1 |   10 | 0.0000000000 | 1.0000000000 |\n|  5 |    2 |   20 | 0.0000000000 | 1.0000000000 |\n|  6 |    2 |   20 | 0.0000000000 | 1.0000000000 |\n|  7 |    2 |   20 | 0.0000000000 | 1.0000000000 |\n|  8 |    2 |   10 | 0.0000000000 | 1.0000000000 |\n|  9 |    4 |   20 | 0.0000000000 | 1.0000000000 |\n| 10 |    4 |   20 | 0.0000000000 | 1.0000000000 |\n+----+------+------+--------------+--------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/percent_rank', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/percent_rank');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (405, 35, 'PERCENTILE\\_CONT', 'Description\n-----------\n\nPERCENTILE_CONT() (standing for continuous percentile) is a window function which returns a value which corresponds to the given fraction in the sort order. If required, it will interpolate between adjacent input items.\n\nEssentially, the following process is followed to find the value to return:\n\n Get the number of rows in the partition, denoted by N\n RN = p\\(N-1), where p denotes the argument to the PERCENTILE_CONT function\n Calculate FRN as FRN=floor(RN) and CRN as CRN=ceil(RN)\n Look up rows FRN and CRN\n If (CRN = FRN = RN) then the result is (value of expression from row at RN)\n Otherwise the result is\n (CRN - RN) \\ (value of expression for row at FRN) +\n (RN - FRN) \\* (value of expression for row at CRN)\n\nThe MEDIAN function is a specific case of PERCENTILE_CONT, equivalent to PERCENTILE_CONT(0.5).\n\nExamples\n--------\n\nCREATE TABLE book_rating (name CHAR(30), star_rating TINYINT);\n\nINSERT INTO book_rating VALUES (''Lord of the Ladybirds'', 5);\nINSERT INTO book_rating VALUES (''Lord of the Ladybirds'', 3);\nINSERT INTO book_rating VALUES (''Lady of the Flies'', 1);\nINSERT INTO book_rating VALUES (''Lady of the Flies'', 2);\nINSERT INTO book_rating VALUES (''Lady of the Flies'', 5);\n\nSELECT name, PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY star_rating) \n  OVER (PARTITION BY name) AS pc \n  FROM book_rating;\n+-----------------------+--------------+\n| name                  | pc           |\n+-----------------------+--------------+\n| Lord of the Ladybirds | 4.0000000000 |\n| Lord of the Ladybirds | 4.0000000000 |\n| Lady of the Flies     | 2.0000000000 |\n| Lady of the Flies     | 2.0000000000 |\n| Lady of the Flies     | 2.0000000000 |\n+-----------------------+--------------+\n\nSELECT name, PERCENTILE_CONT(1) WITHIN GROUP (ORDER BY star_rating) \n  OVER (PARTITION BY name) AS pc \n  FROM book_rating;\n+-----------------------+--------------+\n| name                  | pc           |\n+-----------------------+--------------+\n| Lord of the Ladybirds | 5.0000000000 |\n| Lord of the Ladybirds | 5.0000000000 |\n| Lady of the Flies     | 5.0000000000 |\n| Lady of the Flies     | 5.0000000000 |\n| Lady of the Flies     | 5.0000000000 |\n+-----------------------+--------------+\n\nSELECT name, PERCENTILE_CONT(0) WITHIN GROUP (ORDER BY star_rating) \n  OVER (PARTITION BY name) AS pc \n  FROM book_rating;\n+-----------------------+--------------+\n| name                  | pc           |\n+-----------------------+--------------+\n| Lord of the Ladybirds | 3.0000000000 |\n| Lord of the Ladybirds | 3.0000000000 |\n| Lady of the Flies     | 1.0000000000 |\n| Lady of the Flies     | 1.0000000000 |\n| Lady of the Flies     | 1.0000000000 |\n+-----------------------+--------------+\n\nSELECT name, PERCENTILE_CONT(0.6) WITHIN GROUP (ORDER BY star_rating) \n  OVER (PARTITION BY name) AS pc \n  FROM book_rating;\n+-----------------------+--------------+\n| name                  | pc           |\n+-----------------------+--------------+\n| Lord of the Ladybirds | 4.2000000000 |\n| Lord of the Ladybirds | 4.2000000000 |\n| Lady of the Flies     | 2.6000000000 |\n| Lady of the Flies     | 2.6000000000 |\n| Lady of the Flies     | 2.6000000000 |\n+-----------------------+--------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/percentile_cont', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/percentile_cont');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (406, 35, 'PERCENTILE\\_DISC', 'Description\n-----------\n\nPERCENTILE_DISC() (standing for discrete percentile) is a window function which returns the first value in the set whose ordered position is the same or more than the specified fraction.\n\nEssentially, the following process is followed to find the value to return:\n\n Get the number of rows in the partition.\n Walk through the partition, in order, until finding the first row with CUME_DIST() >= function_argument.\n\nExamples\n--------\n\nCREATE TABLE book_rating (name CHAR(30), star_rating TINYINT);\n\nINSERT INTO book_rating VALUES (''Lord of the Ladybirds'', 5);\nINSERT INTO book_rating VALUES (''Lord of the Ladybirds'', 3);\nINSERT INTO book_rating VALUES (''Lady of the Flies'', 1);\nINSERT INTO book_rating VALUES (''Lady of the Flies'', 2);\nINSERT INTO book_rating VALUES (''Lady of the Flies'', 5);\n\nSELECT name, PERCENTILE_DISC(0.5) WITHIN GROUP (ORDER BY star_rating)\n  OVER (PARTITION BY name) AS pc FROM book_rating;\n+-----------------------+------+\n| name                  | pc   |\n+-----------------------+------+\n| Lord of the Ladybirds |    3 |\n| Lord of the Ladybirds |    3 |\n| Lady of the Flies     |    2 |\n| Lady of the Flies     |    2 |\n| Lady of the Flies     |    2 |\n+-----------------------+------+\n5 rows in set (0.000 sec)\n\nSELECT name, PERCENTILE_DISC(0) WITHIN GROUP (ORDER BY star_rating) \n OVER (PARTITION BY name) AS pc FROM book_rating;\n+-----------------------+------+\n| name                  | pc   |\n+-----------------------+------+\n| Lord of the Ladybirds |    3 |\n| Lord of the Ladybirds |    3 |\n| Lady of the Flies     |    1 |\n| Lady of the Flies     |    1 |\n| Lady of the Flies     |    1 |\n+-----------------------+------+\n5 rows in set (0.000 sec)\n\nSELECT name, PERCENTILE_DISC(1) WITHIN GROUP (ORDER BY star_rating) \n  OVER (PARTITION BY name) AS pc FROM book_rating;\n+-----------------------+------+\n| name                  | pc   |\n+-----------------------+------+\n| Lord of the Ladybirds |    5 |\n| Lord of the Ladybirds |    5 |\n| Lady of the Flies     |    5 |\n| Lady of the Flies     |    5 |\n| Lady of the Flies     |    5 |\n+-----------------------+------+\n5 rows in set (0.000 sec)\n\nSELECT name, PERCENTILE_DISC(0.6) WITHIN GROUP (ORDER BY star_rating) \n  OVER (PARTITION BY name) AS pc FROM book_rating;\n+-----------------------+------+\n| name                  | pc   |\n+-----------------------+------+\n| Lord of the Ladybirds |    5 |\n| Lord of the Ladybirds |    5 |\n| Lady of the Flies     |    2 |\n| Lady of the Flies     |    2 |\n| Lady of the Flies     |    2 |\n+-----------------------+------\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/percentile_disc', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/percentile_disc');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (407, 35, 'RANK', 'Syntax\n------\n\nRANK() OVER (\n  [ PARTITION BY partition_expression ]\n  [ ORDER BY order_list ]\n)\n\nDescription\n-----------\n\nRANK() is a window function that displays the number of a given row, starting at one and following the ORDER BY sequence of the window function, with identical values receiving the same result. It is similar to the ROW_NUMBER() function except that in that function, identical values will receive a different row number for each result.\n\nExamples\n--------\n\nCREATE TABLE student(course VARCHAR(10), mark int, name varchar(10));\n\nINSERT INTO student VALUES \n  (''Maths'', 60, ''Thulile''),\n  (''Maths'', 60, ''Pritha''),\n  (''Maths'', 70, ''Voitto''),\n  (''Maths'', 55, ''Chun''),\n  (''Biology'', 60, ''Bilal''),\n   (''Biology'', 70, ''Roger'');\n\nSELECT \n  RANK() OVER (PARTITION BY course ORDER BY mark DESC) AS rank, \n  DENSE_RANK() OVER (PARTITION BY course ORDER BY mark DESC) AS dense_rank, \n  ROW_NUMBER() OVER (PARTITION BY course ORDER BY mark DESC) AS row_num, \n  course, mark, name \nFROM student ORDER BY course, mark DESC;\n+------+------------+---------+---------+------+---------+\n| rank | dense_rank | row_num | course  | mark | name    |\n+------+------------+---------+---------+------+---------+\n|    1 |          1 |       1 | Biology |   70 | Roger   |\n|    2 |          2 |       2 | Biology |   60 | Bilal   |\n|    1 |          1 |       1 | Maths   |   70 | Voitto  |\n|    2 |          2 |       2 | Maths   |   60 | Thulile |\n|    2 |          2 |       3 | Maths   |   60 | Pritha  |\n|    4 |          3 |       4 | Maths   |   55 | Chun    |\n+------+------------+---------+---------+------+---------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/rank', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/rank');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (408, 35, 'ROW\\_NUMBER', 'Syntax\n------\n\nROW_NUMBER() OVER (\n  [ PARTITION BY partition_expression ]\n  [ ORDER BY order_list ]\n)\n\nDescription\n-----------\n\nROW_NUMBER() is a window function that displays the number of a given row, starting at one and following the ORDER BY sequence of the window function, with identical values receiving different row numbers. It is similar to the RANK() and DENSE_RANK() functions except that in that function, identical values will receive the same rank for each result.\n\nExamples\n--------\n\nCREATE TABLE student(course VARCHAR(10), mark int, name varchar(10));\n\nINSERT INTO student VALUES \n  (''Maths'', 60, ''Thulile''),\n  (''Maths'', 60, ''Pritha''),\n  (''Maths'', 70, ''Voitto''),\n  (''Maths'', 55, ''Chun''),\n  (''Biology'', 60, ''Bilal''),\n   (''Biology'', 70, ''Roger'');\n\nSELECT \n  RANK() OVER (PARTITION BY course ORDER BY mark DESC) AS rank, \n  DENSE_RANK() OVER (PARTITION BY course ORDER BY mark DESC) AS dense_rank, \n  ROW_NUMBER() OVER (PARTITION BY course ORDER BY mark DESC) AS row_num, \n  course, mark, name \nFROM student ORDER BY course, mark DESC;\n+------+------------+---------+---------+------+---------+\n| rank | dense_rank | row_num | course  | mark | name    |\n+------+------------+---------+---------+------+---------+\n|    1 |          1 |       1 | Biology |   70 | Roger   |\n|    2 |          2 |       2 | Biology |   60 | Bilal   |\n|    1 |          1 |       1 | Maths   |   70 | Voitto  |\n|    2 |          2 |       2 | Maths   |   60 | Thulile |\n|    2 |          2 |       3 | Maths   |   60 | Pritha  |\n|    4 |          3 |       4 | Maths   |   55 | Chun    |\n+------+------------+---------+---------+------+---------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/row_number', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/row_number');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (409, 35, 'Window Frames', 'Description\n-----------\n\nBasic Syntax\n\n``sql\nframe_clause:\n  {ROWS | RANGE} {frame_border | BETWEEN frame_border AND frame_border}\n\nframe_border:\n  | UNBOUNDED PRECEDING\n  | UNBOUNDED FOLLOWING\n  | CURRENT ROW\n  | expr PRECEDING\n  | expr FOLLOWING\n`\n\nHow Window Frames Work\n\nA basic overview of window functions is described in Window Functions Overview. Window frames define which rows contribute to the current result.\n\nWindow frames are used by aggregate window functions. They are defined by the frame clause inside OVER (...).\n\nOVER () uses the whole result set.\n\nFor aggregate window functions, OVER (ORDER BY ...) uses a running frame by default. In MariaDB, that default is RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW.\n\nFrame Bound Types\n\nCommon frame bounds include:\n\n All rows before the current row (UNBOUNDED PRECEDING), for example RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW .\n All rows after the current row (UNBOUNDED FOLLOWING), for example RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING .\n A set number of rows before the current row (expr PRECEDING), for example RANGE BETWEEN 6 PRECEDING AND CURRENT ROW .\n A set number of rows after the current row (expr FOLLOWING), for example RANGE BETWEEN CURRENT ROW AND 2 FOLLOWING .\n* A specified number of rows both before and after the current row, for example RANGE BETWEEN 6 PRECEDING AND 3 FOLLOWING .\n\nROWS vs RANGE\n\nROWS counts physical rows. RANGE groups peer rows that share the same ORDER BY value.\n\nUse ROWS when you want strict row-by-row stepping. Use RANGE when tied sort values should be treated as one peer group.\n\nAggregate Functions Using Frames\n\nSee list here.\n\nExamples\n--------\n\nCREATE TABLE student_test` (\n  name char(10),\n  test char(10),\n  score tinyint(4)\n);\n\nINSERT INTO student_test VALUES \n    (''Chun'', ''SQL'', 75), (''Chun'', ''Tuning'', 73), \n    (''Esben'', ''SQL'', 43), (''Esben'', ''Tuning'', 31), \n    (''Kaolin'', ''SQL'', 56), (''Kaolin'', ''Tuning'', 88), \n    (''Tatiana'', ''SQL'', 87);\n\nSELECT name, test, score, SUM(score) \n  OVER () AS total_score \n  FROM student_test;\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/window-frames', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/window-frames');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (410, 35, 'ColumnStore Window Functions', 'Description\n-----------\n\nIntroduction\n\nMariaDB ColumnStore provides support for window functions broadly following the SQL 2003 specification. A window function allows for calculations relating to a window of data surrounding the current row in a result set. This capability provides for simplified queries in support of common business questions such as cumulative totals, rolling averages, and top 10 lists.\n\nAggregate functions are utilized for window functions however differ in behavior from a group by query because the rows remain ungrouped. This provides support for cumulative sums and rolling averages, for example.\n\nTwo key concepts for window functions are Partition and Frame:\n\n A Partition is a group of rows, or window, that have the same value for a specific column, for example a Partition can be created over a time period such as a quarter or lookup values.\n The Frame for each row is a subset of the row''s Partition. The frame typically is dynamic allowing for a sliding frame of rows within the Partition. The Frame determines the range of rows for the windowing function. A Frame could be defined as the last X rows and next Y rows all the way up to the entire Partition.\n\nWindow functions are applied after joins, group by, and having clauses are calculated.\n\nSyntax\n\nA window function is applied in the select clause using the following syntax:\n\n``sql\nfunction_name ([expression [, expression ... ]]) OVER ( window_definition )\n`\n\nwhere _window_definition_ is defined as:\n\n`sql\n[ PARTITION BY expression [, ...] ]\n[ ORDER BY expression [ ASC | DESC ] [ NULLS { FIRST | LAST } ] [, ...] ]\n[ frame_clause ]\n`\n\nPARTITION BY:\n\n Divides the window result set into groups based on one or more expressions.\n An expression may be a constant, column, and non window function expressions.\n A query is not limited to a single partition by clause. Different partition clauses can be used across different window function applications.\n The partition by columns do not need to be in the select list but do need to be available from the query result set.\n If there is no PARTITION BY clause, all rows of the result set define the group.\n\nORDER BY:\n\n Defines the ordering of values within the partition.\n Can be ordered by multiple keys which may be a constant, column or non window function expression.\n The order by columns do not need to be in the select list but need to be available from the query result set.\n Use of a select column alias from the query is not supported.\n ASC (default) and DESC options allow for ordering ascending or descending.\n NULLS FIRST and NULL_LAST options specify whether null values come first or last in the ordering sequence. NULLS_FIRST is the default for ASC order, and NULLS_LAST is the default for DESC order.\n\nand the optional _frame_clause_ is defined as:\n\n`sql\n{ RANGE | ROWS } frame_start\n{ RANGE | ROWS } BETWEEN frame_start AND frame_end\n`\n\nand the optional _frame_start_ and _frame_end_ are defined as (value being a numeric expression):\n\n`sql\nUNBOUNDED PRECEDING\nvalue PRECEDING\nCURRENT ROW\nvalue FOLLOWING\nUNBOUNDED FOLLOWING\n`\n\nRANGE/ROWS:\n\n Defines the windowing clause for calculating the set of rows that the function applies to for calculating a given rows window function result.\n Requires an ORDER BY clause to define the row order for the window.\n ROWS specify the window in physical units, i.e. result set rows and must be a constant or expression evaluating to a positive numeric value.\n RANGE specifies the window as a logical offset. If the expression evaluates to a numeric value then the ORDER BY expression must be a numeric or DATE type. If the expression evaluates to an interval value then the ORDER BY expression must be a DATE data type.\n UNBOUNDED PRECEDING indicates the window starts at the first row of the partition.\n UNBOUNDED FOLLOWING indicates the window ends at the last row of the partition.\n CURRENT ROW specifies the window start or ends at the current row or value.\n* If omitted, the default is ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW`.\n\nSupported Functions\n\n| Function               | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |\n| ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| AVG()                  | The average of all input values.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |\n| COUNT()                | Number of input rows.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |\n| CUME_DIST()           | Calculates the cumulative distribution, or relative rank, of the current row to other rows in the same partition. Number of peer or preceding rows / number of rows in partition.                                                                                                                                                                                                                                                                                                                                                  |\n| DENSE_RANK()          | Ranks items in a group leaving no gaps in ranking sequence when there are ties.                                                                                                                                                                                                                                                                                                                                                                                                                                                    |\n| FIRST_VALUE()         | The value evaluated at the row that is the first row of the window frame (counting from 1); null if no such row.                                                                                                                                                                                                                                                                                                                                                                                                                   |\n| LAG()                  | The value evaluated at the row that is offset rows before the current row within the partition; if there is no such row, instead return default. Both offset and default are evaluated with respect to the current row. If omitted, offset defaults to 1 and default to null. LAG provides access to more than one row of a table at the same time without a self-join. Given a series of rows returned from a query and a position of the cursor, LAG provides access to a row at a given physical offset prior to that position. |\n| LAST_VALUE()          | The value evaluated at the row that is the last row of the window frame (counting from 1); null if no such row.                                                                                                                                                                                                                                                                                                                                                                                                                    |\n| LEAD()                 | Provides access to a row at a given physical offset beyond that position. Returns value evaluated at the row that is offset rows after the current row within the partition; if there is no such row, instead return default. Both offset and default are evaluated with respect to the current row. If omitted, offset defaults to 1 and default to null.                                                                                                                                                                         |\n| MAX()                  | Maximum value of expression across all input values.                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |\n| MEDIAN()               | An inverse distribution function that assumes a continuous distribution model. It takes a numeric or datetime value and returns the middle value or an interpolated value that would be the middle value once the values are sorted. Nulls are ignored in the calculation.                                                                                                                                                                                                                                                         |\n| MIN()                  | Minimum value of expression across all input values.                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |\n| NTH_VALUE()           | The value evaluated at the row that is the nth row of the window frame (counting from 1); null if no such row.                                                                                                                                                                                                                                                                                                                                                                                                                     |\n| NTILE()                | Divides an ordered data set into a number of buckets indicated by expr and assigns the appropriate bucket number to each row. The buckets are numbered 1 through expr. The expr value must resolve to a positive constant for each partition. Integer ranging from 1 to the argument value, dividing the partition as equally as possible.                                                                                                                                                                                         |\n| PERCENT_RANK()        | relative rank of the current row: (rank - 1) / (total rows - 1).                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |\n| PERCENTILE_CONT()     | An inverse distribution function that assumes a continuous distribution model. It takes a percentile value and a sort specification, and returns an interpolated value that would fall into that percentile value with respect to the sort specification. Nulls are ignored in the calculation.                                                                                                                                                                                                                                    |\n| PERCENTILE_DISC()     | An inverse distribution function that assumes a discrete distribution model. It takes a percentile value and a sort specification and returns an element from the set. Nulls are ignored in the calculation.                                                                                                                                                                                                                                                                                                                       |\n| RANK()                 | rank of the current row with gaps; same as row_number of its first peer.                                                                                                                                                                                                                                                                                                                                                                                                                                                          |\n| ROW_NUMBER()          | number of the current row within its partition, counting from 1                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |\n| STDDEV() STDDEV_POP() | Computes the population standard deviation a\n\n[Truncated — full content at mariadb.com/docs]', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/window-functions-columnstore-window-functions');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (411, 35, 'Window Functions Overview', 'Description\n-----------\n\nWindow Functions\n\nWindow functions calculate across related rows without collapsing them. Unlike GROUP BY, they return one result for each input row.\n\nWhen to Use Window Functions\n\nUse window functions when you need to:\n\n Rank rows inside a group.\n Calculate running totals or moving averages.\n Compare a row with earlier or later rows.\n Return the top _N_ rows per group.\n\nBasic Syntax\n\n``sql\nwindow_function(expr) OVER (\n  [PARTITION BY expr [, ...]]\n  [ORDER BY expr [ASC | DESC] [, ...]]\n  [{ROWS | RANGE} frame_clause]\n)\n\nframe_clause:\n  {frame_border | BETWEEN frame_border AND frame_border}\n\nframe_border:\n  UNBOUNDED PRECEDING\n  | UNBOUNDED FOLLOWING\n  | CURRENT ROW\n  | expr PRECEDING\n  | expr FOLLOWING\n`\n\nYou can also define a named window and reuse it:\n\n`sql\nSELECT\n  SUM(score) OVER w AS running_total,\n  AVG(score) OVER w AS running_avg\nFROM student\nWINDOW w AS (\n  ORDER BY score\n  ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW\n);\n`\n\nWindow Functions vs GROUP BY\n\nUse GROUP BY when you want one output row per group.\n\nUse a window function when you want to keep the original rows and add per-group or per-sequence calculations beside them.\n\n`sql\nSELECT test, AVG(score)\nFROM student\nGROUP BY test;\n`\n\nThis returns one row per test.\n\n`sql\nSELECT\n  name,\n  test,\n  score,\n  AVG(score) OVER (PARTITION BY test) AS avg_by_test\nFROM student;\n`\n\nThis returns every row, plus the average for that row''s test.\n\nHow OVER Works\n\nPARTITION BY\n\nPARTITION BY starts a new calculation for each group.\n\nORDER BY\n\nORDER BY defines the row sequence inside each partition.\n\nFrame\n\nThe frame controls which rows contribute to the current result. Aggregate window functions use frames. Ranking functions such as ROW_NUMBER() and RANK() do not.\n\nOVER () uses the whole result set.\n\nFor aggregate window functions, OVER (ORDER BY ...) uses a running frame by default. In MariaDB, that default is RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW.\n\nROWS vs RANGE\n\nROWS counts physical rows. RANGE groups peer rows that share the same ORDER BY value.\n\nUse ROWS when you need strict row-by-row stepping. Use RANGE when ties should be treated as one peer group.\n\n`sql\nCREATE TABLE t (score INT);\nINSERT INTO t VALUES (10), (10), (20);\n\nSELECT\n  score,\n  SUM(score) OVER (\n    ORDER BY score\n    ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW\n  ) AS rows_sum,\n  SUM(score) OVER (\n    ORDER BY score\n    RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW\n  ) AS range_sum\nFROM t;\n`\n\nThis produces different results for the duplicate 10 values:\n\n`\n+-------+----------+-----------+\n| score | rows_sum | range_sum |\n+-------+----------+-----------+\n|    10 |       10 |        20 |\n|    10 |       20 |        20 |\n|    20 |       40 |        40 |\n+-------+----------+-----------+\n`\n\nSupported Functions\n\nDedicated window functions include CUME_DIST, DENSE_RANK, FIRST_VALUE, LAG, LAST_VALUE, LEAD, MEDIAN, NTH_VALUE, NTILE, PERCENTILE_CONT, PERCENTILE_DISC, PERCENT_RANK, RANK, and ROW_NUMBER.\n\nAggregate functions that also work with OVER (...) include AVG, BIT_AND, BIT_OR, BIT_XOR, COUNT, MAX, MIN, STD, STDDEV, STDDEV_POP, STDDEV_SAMP, SUM, VAR_POP, VAR_SAMP, and VARIANCE.\n\nAggregate window functions do not support DISTINCT.\n\nAggregate Functions as Window Functions\n\nIt is possible to use aggregate functions as window functions. An aggregate function used as a window function must have the OVER clause. For example, here''s COUNT() used as a window function:\n\n`sql\nSELECT COUNT() OVER (ORDER BY column) FROM table;\n`\n\nCommon Pitfalls\n\n You cannot reference a window function in WHERE.\n Compute the window result in a subquery or CTE first.\n MariaDB does not support GROUPS frames.\n MariaDB does not support frame exclusion.\n MariaDB does not support explicit NULLS FIRST or NULLS LAST.\n RANGE frames do not support DATE or DATETIME arithmetic.\n\nWindow functions are evaluated after WHERE, GROUP BY, and HAVING. Filter the computed result in an outer query or CTE.\n\nOptimization\n\nWindow functions often need sorted input. Query shape can decide whether MariaDB can reuse an existing order or must sort again.\n\nGROUP BY Comes First\n\nIf a query uses both GROUP BY and window functions, MariaDB executes the grouping step first. The window step runs on the grouped result.\n\nThis affects index usage. An index that helps the base table scan does not automatically avoid later sorting for the window stage.\n\nWhen tuning this pattern, optimize the GROUP BY step first. Then check whether the window step still needs its own sort.\n\nSort Reuse Depends on Sort Keys\n\nIf the GROUP BY definition and the window''s PARTITION BY and ORDER BY definition use different sort keys, MariaDB usually needs another sort pass before evaluating the window functions.\n\nFor example, this shape can require an extra sort:\n\n`sql\nSELECT\n  dept,\n  month,\n  SUM(sales) AS monthly_sales,\n  ROW_NUMBER() OVER (\n    PARTITION BY dept\n    ORDER BY month\n  ) AS row_num\nFROM revenue\nGROUP BY month, dept;\n`\n\nThe grouped result is ordered by month, dept. The window step needs dept, month. Those orders do not match.\n\nMultiple Window Functions Can Share One Sort\n\nMultiple window functions can share the same sort pass when they use the same PARTITION BY and ORDER BY clause.\n\n`sql\nSELECT\n  dept,\n  month,\n  sales,\n  ROW_NUMBER() OVER (\n    PARTITION BY dept\n    ORDER BY month\n  ) AS row_num,\n  SUM(sales) OVER (\n    PARTITION BY dept\n    ORDER BY month\n    ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW\n  ) AS running_sales\nFROM revenue;\n`\n\nBoth window functions use the same partitioning and ordering. MariaDB can reuse the same sorted stream for both.\n\nPractical Tuning Tips\n\n Expect GROUP BY to shape the input seen by window functions.\n Align GROUP BY keys with the window sort keys when possible.\n Reuse the same PARTITION BY and ORDER BY` across multiple window functions.\n* Check the execution plan to see whether an extra sort is still present.\n\nExamples\n--------\n\nCREATE TABLE student (\n  name CHAR(10),\n  test CHAR(10),\n  score TINYINT\n);\n\nINSERT INTO student VALUES\n  (''Chun'', ''SQL'', 75), (''Chun'', ''Tuning'', 73),\n  (''Esben'', ''SQL'', 43), (''Esben'', ''Tuning'', 31),\n  (''Kaolin'', ''SQL'', 56), (''Kaolin'', ''Tuning'', 88),\n  (''Tatiana'', ''SQL'', 87), (''Tatiana'', ''Tuning'', 83);\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/window-functions-overview', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/window-functions-overview');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (412, 37, 'ASCII', 'Syntax\n------\n\nASCII(str)\n\nDescription\n-----------\n\nReturns the numeric ASCII value of the leftmost character of the string argument. Returns 0 if the given string is empty and NULL if it is NULL.\n\nASCII() works for 8-bit characters.\n\nExamples\n--------\n\nSELECT ASCII(9);\n+----------+\n| ASCII(9) |\n+----------+\n|       57 |\n+----------+\n\nSELECT ASCII(''9'');\n+------------+\n| ASCII(''9'') |\n+------------+\n|         57 |\n+------------+\n\nSELECT ASCII(''abc'');\n+--------------+\n| ASCII(''abc'') |\n+--------------+\n|           97 |\n+--------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/ascii', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/ascii');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (413, 37, 'BIN', 'Syntax\n------\n\nBIN(N)\n\nDescription\n-----------\n\nReturns a string representation of the binary value of the given longlong (that is, BIGINT) number. This is equivalent to CONV(N,10,2). The argument should be positive. If it is a FLOAT, it will be truncated. Returns NULL if the argument is NULL.\n\nExamples\n--------\n\nSELECT BIN(12);\n+---------+\n| BIN(12) |\n+---------+\n| 1100    |\n+---------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/bin', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/bin');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (414, 37, 'BINARY Operator', 'Syntax\n------\n\nBINARY\n\nDescription\n-----------\n\nThe BINARY operator casts the string following it to a binary string. This is an easy way to force a column comparison to be done byte by byte rather than character by character. This causes the comparison to be case sensitive even if the column isn''t defined as BINARY or BLOB.\n\nBINARY also causes trailing spaces to be significant.\n\nExamples\n--------\n\nSELECT ''a'' = ''A'';\n+-----------+\n| ''a'' = ''A'' |\n+-----------+\n|         1 |\n+-----------+\n\nSELECT BINARY ''a'' = ''A'';\n+------------------+\n| BINARY ''a'' = ''A'' |\n+------------------+\n|                0 |\n+------------------+\n\nSELECT ''a'' = ''a '';\n+------------+\n| ''a'' = ''a '' |\n+------------+\n|          1 |\n+------------+\n\nSELECT BINARY ''a'' = ''a '';\n+-------------------+\n| BINARY ''a'' = ''a '' |\n+-------------------+\n|                 0 |\n+-------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/binary-operator', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/binary-operator');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (415, 37, 'BIT\\_LENGTH', 'Syntax\n------\n\nBIT_LENGTH(str)\n\nDescription\n-----------\n\nReturns the length of the given string argument in bits. If the argument is not a string, it will be converted to string. If the argument is NULL, it returns NULL.\n\nExamples\n--------\n\nSELECT BIT_LENGTH(''text'');\n+--------------------+\n| BIT_LENGTH(''text'') |\n+--------------------+\n|                 32 |\n+--------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/bit_length', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/bit_length');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (416, 37, 'CAST', 'Syntax\n------\n\nCAST(expr AS type)\n\nDescription\n-----------\n\nThe CAST() function takes a value of one data type and produces a value of another data type, similar to the CONVERT() function.\n\nThe type can be one of the following values:\n\n BINARY\n CHAR\n DATE\n DATETIME\n DECIMAL\n DOUBLE\n FLOAT\n INTEGER (short for SIGNED INTEGER )\n [SIGNED \\[INTEGER\\]](../../data-types/numeric-data-types/integer.md)\n [UNSIGNED \\[INTEGER\\]](../../data-types/numeric-data-types/integer.md)\n TIME\n VARCHAR\n* XMLTYPE (Available starting with MariaDB 12.3)\n\nThe main difference between CAST and CONVERT() is that CONVERT(expr,type) is ODBC syntax, while CAST(expr as type) and CONVERT(... USING ...) are SQL92 syntax.\n\nTo cast a value to a string data type while specifying the character set, use this extended syntax:\n\n``sql\n CAST(expr AS CHAR CHARACTER SET name)\n`\n\nSee the examples for casting to character sets.\n\nUsing an introducer like _utf8mb4''text'' is often more efficient than CAST(''text'' AS CHAR CHARACTER SET utf8mb4), but CAST is necessary when converting data types (like numbers to strings) into a specific encoding. See this example, too.\n\nYou can use the CAST() function with the INTERVAL` keyword.\n\nThis introduced an incompatibility with previous versions of MariaDB, and all versions of MySQL (see the example below).\n\nExamples\n--------\n\nSELECT CAST("abc" AS BINARY);\nSELECT CAST("1" AS UNSIGNED INTEGER);\nSELECT CAST(123 AS CHAR CHARACTER SET utf8)\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/cast', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/cast');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (417, 37, 'CHAR Function', 'Syntax\n------\n\nCHAR(N,... [USING charset_name])\n\nDescription\n-----------\n\nCHAR() interprets each argument as an INT and returns a string consisting of the characters given by the code values of those integers. NULL values are skipped. By default, CHAR() returns a binary string. To produce a string in a given character set, use the optional USING clause:\n\n``sql\nSELECT CHARSET(CHAR(0x65)), CHARSET(CHAR(0x65 USING utf8));\n+---------------------+--------------------------------+\n| CHARSET(CHAR(0x65)) | CHARSET(CHAR(0x65 USING utf8)) |\n+---------------------+--------------------------------+\n| binary              | utf8                           |\n+---------------------+--------------------------------+\n`\n\nIf USING is given and the result string is illegal for the given character set, a warning is issued. Also, if strict SQL mode is enabled, the result from CHAR() becomes NULL`.\n\nExamples\n--------\n\nSELECT CHAR(77,97,114,''105'',97,''68'',66);\n+----------------------------------+\n| CHAR(77,97,114,''105'',97,''68'',66) |\n+----------------------------------+\n| MariaDB                          |\n+----------------------------------+\n\nSELECT CHAR(77,77.3,''77.3'');\n+----------------------+\n| CHAR(77,77.3,''77.3'') |\n+----------------------+\n| MMM                  |\n+----------------------+\n1 row in set, 1 warning (0.00 sec)\n\nWarning (Code 1292): Truncated incorrect INTEGER value: ''77.3''\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/char-function', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/char-function');
