INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (641, 39, 'DROP TABLE', 'Syntax\n------\n\nDROP [TEMPORARY] TABLE [IF EXISTS] [/COMMENT TO SAVE/]\n    tbl_name [, tbl_name] ...\n    [WAIT n|NOWAIT]\n    [RESTRICT | CASCADE]\n\nDescription\n-----------\n\nDROP TABLE removes one or more tables. You must have the DROP privilege for each table. All table data and the table definition are removed, as well as triggers associated to the table, so be careful with this statement! If any of the tables named in the argument list do not exist, MariaDB returns an error indicating by name which non-existing tables it was unable to drop, but it also drops all of the tables in the list that do exist.\n\nImportant: When a table is dropped, user privileges on the table are not automatically dropped. See GRANT.\n\nIf another thread is using the table in an explicit transaction or an autocommit transaction, then the thread acquires a metadata lock (MDL) on the table. The DROP TABLE statement will wait in the "Waiting for table metadata lock" thread state until the MDL is released. MDLs are released in the following cases:\n\n If an MDL is acquired in an explicit transaction, then the MDL will be released when the transaction ends.\n If an MDL is acquired in an autocommit transaction, then the MDL will be released when the statement ends.\n Transactional and non-transactional tables are handled the same.\n\nNote that for a partitioned table, DROP TABLE permanently removes the table definition, all of its partitions, and all of the data which was stored in those partitions. It also removes the partitioning definition (.par) file associated with the dropped table.\n\nFor each referenced table, DROP TABLE drops a temporary table with that name, if it exists. If it does not exist, and the TEMPORARY keyword is not used, it drops a non-temporary table with the same name, if it exists. The TEMPORARY keyword ensures that a non-temporary table will not accidentally be dropped.\n\nUse IF EXISTS to prevent an error from occurring for tables that do not\\\nexist. A NOTE is generated for each non-existent table when usingIF EXISTS. See SHOW WARNINGS.\n\nIf a foreign key references this table, the table cannot be dropped. In this case, it is necessary to drop the foreign key first.\n\nRESTRICT and CASCADE are allowed to make porting from other database systems easier. In MariaDB, they do nothing.\n\nThe comment before the table names (/COMMENT TO SAVE/) is stored in the binary log. That feature can be used by replication tools to send their internal messages.\n\nIt is possible to specify table names as db_name.tab_name. This is useful to delete tables from multiple databases with one statement. See Identifier Qualifiers for details.\n\nThe DROP privilege is required to use DROP TABLE on non-temporary tables. For temporary tables, no privilege is required, because such tables are only visible for the current session.\n\nNote: DROP TABLE automatically commits the current active transaction, unless you use the TEMPORARY keyword.\n\nDROP TABLE reliably deletes table remnants inside a storage engine even if the .frm file is missing.\n\nDROP TABLE does not reliably delete table remnants inside a storage engine even if the .frm file is missing. A missing .frm file will result in the statement failing.\n\nWAIT/NOWAIT\n\nSet the lock wait timeout. See WAIT and NOWAIT.\n\nDROP TABLE in replication\n\nDROP TABLE has the following characteristics in replication:\n\n DROP TABLE IF EXISTS are always logged.\n DROP TABLE without IF EXISTS for tables that don''t exist are not written to the binary log.\n Dropping of TEMPORARY tables are prefixed in the log with TEMPORARY. These drops are only logged when running statement or mixed mode replication.\n One DROP TABLE statement can be logged with up to 3 different DROP statements:\n   DROP TEMPORARY TABLE list_of_non_transactional_temporary_tables\n   DROP TEMPORARY TABLE list_of_transactional_temporary_tables\n   DROP TABLE list_of_normal_tables\n\nDROP TABLE on the master is treated on the slave as DROP TABLE IF EXISTS. You can change that by setting slave-ddl-exec-mode to STRICT.\n\nDropping an Internal #sql-... Table\n\nDROP TABLE is atomic.\n\nif the mariadbd process is killed during an ALTER TABLE, you may find a table named #sql-... in your data directory. These temporary tables will always be deleted automatically.\n\nIf you want to delete one of these tables explicitly you can do so by using the following syntax:\n\n``\nDROP TABLE #mysql50##sql-...;\n`\n\nWhen running an ALTER TABLE…ALGORITHM=INPLACE that rebuilds the table, InnoDB will create an internal #sql-ib table.\n\nThe same name as the .frm file is used for the intermediate copy of the table. The #sql-ib names are used by TRUNCATE and delayed DROP.\n\nThe #sql-ib tables will be deleted automatically.\n\nDropping All Tables in a Database\n\nThe best way to drop all tables in a database is by executing DROP DATABASE, which will drop the database itself, and all tables in it.\n\nHowever, if you want to drop all tables in the database, but you also want to keep the database itself and any other non-table objects in it, then you would need to execute DROP TABLE to drop each individual table. You can construct these DROP TABLE commands by querying the TABLES table in the information_schema database. For example:\n\n`\nSELECT CONCAT(''DROP TABLE IF EXISTS '', TABLE_SCHEMA, ''.'', TABLE_NAME, '';'')\nFROM information_schema.TABLES\nWHERE TABLE_SCHEMA = ''mydb'';\n`\n\nAtomic DROP TABLE\n\nMariaDB starting with 10.6.1\n\nDROP TABLE for a single table is atomic (MDEV-25180) for most engines, including InnoDB, MyRocks, MyISAM and Aria. This means that if there is a crash (server down or power outage) during DROP TABLE, all tables that have been processed so far will be completely dropped, including related trigger files and status entries, and the binary log will include a DROP TABLE statement for the dropped tables. Tables for which the drop had not started will be left intact.DROP TABLE was extended to be able to delete a table that was only partly dropped (MDEV-11412), as explained above. Atomic DROP TABLE is the final piece to make DROP TABLE fully reliable. Dropping multiple tables is crash-safe. See Atomic DDL for more information.\n\nThere is a small chance that, during a server crash happening in the middle of DROP TABLE, some storage engines that were using multiple storage files, like MyISAM, could have only a part of its internal files dropped. In MariaDB 10.5, DROP TABLE was extended to be able to delete a table that was only partly dropped (MDEV-11412) as explained above. Atomic DROP TABLE is the final piece to make DROP TABLE` fully reliable. Dropping multiple tables is crash-safe. See Atomic DDL for more information.\n\nExamples\n--------\n\nDROP TABLE Employees, Customers;\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-definition/drop/drop-table', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-definition/drop/drop-table');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (642, 39, 'DROP TABLESPACE', 'Description\n-----------\n\nThe DROP TABLESPACE statement is not supported by MariaDB. It was originally inherited from MySQL NDB Cluster. In MySQL 5.7 and later, the statement is also supported for InnoDB. However, MariaDB has chosen not to include that specific feature. See MDEV-19294 for more information.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-definition/drop/drop-tablespace', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-definition/drop/drop-tablespace');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (643, 39, 'DROP TRIGGER', 'Syntax\n------\n\nDROP TRIGGER [IF EXISTS] [schema_name.]trigger_name\n\nDescription\n-----------\n\nThis statement drops a trigger. The schema (database) name is optional. If the schema is omitted, the trigger is dropped from the default schema. Its use requires the TRIGGER privilege for the table associated with the trigger.\n\nUse IF EXISTS to prevent an error from occurring for a trigger that does not exist. A NOTE is generated for a non-existent trigger when using IF EXISTS. See SHOW WARNINGS.\n\nNote: Triggers for a table are also dropped if you drop the table.\n\nAtomic DDL\n\nDROP TRIGGER is atomic.\n\nDROP TRIGGER is not atomic.\n\nExamples\n--------\n\nDROP TRIGGER test.example_trigger;\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-definition/drop/drop-trigger', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-definition/drop/drop-trigger');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (644, 39, 'RENAME TABLE', 'Syntax\n------\n\nRENAME TABLE[S] [IF EXISTS] tbl_name \n  [WAIT n | NOWAIT]\n  TO new_tbl_name\n    [, tbl_name2 TO new_tbl_name2] ...\n\nDescription\n-----------\n\nThis statement renames one or more tables or views, but not the privileges associated with them. For InnoDB tables, it also triggers a reload of InnoDB statistics.\n\nIF EXISTS\n\nIf this clause is used, you don''t get an error if the table to be renamed doesn''t exist.\n\nThe rename operation is done atomically, which means that no other session can access any of the tables while the rename is running. For example, if you have an existing table old_table, you can create another table new_table that has the same structure but is empty, and then replace the existing table with the empty one as follows (assuming that backup_table does not already exist):\n\n``sql\nCREATE TABLE new_table (...);\nRENAME TABLE old_table TO backup_table, new_table TO old_table;\n`\n\nMoving Tables to Another Database\n\ntbl_name can optionally be specified as db_name.tbl_name. See Identifier Qualifiers. This allows to use RENAME to move a table from a database to another (as long as they are on the same filesystem):\n\n`sql\nRENAME TABLE db1.t TO db2.t;\n`\n\nLimitations of Moving Tables to Another Database\n\nNote that moving a table to another database is not possible if it has triggers.\n\nTrying to do so produces the following error:\n\n`sql\nERROR 1435 (HY000): Trigger in wrong schema\n`\n\nViews cannot be moved to another database.\n\nTrying to do so produces the following error:\n\n`sql\nERROR 1450 (HY000): Changing schema from ''old_db'' to ''new_db'' is not allowed.\n`\n\nRenaming Multiple Tables at Once\n\nMultiple tables can be renamed in a single statement. The presence or absence of the optional S (RENAME TABLE or RENAME TABLES) has no impact, whether a single or multiple tables are being renamed.\n\nIf a RENAME TABLE renames more than one table and one renaming fails, all renames executed by the same statement are rolled back.\n\nRenames are always executed in the specified order. Knowing this, it is also possible to swap two tables'' names:\n\n`sql\nRENAME TABLE t1 TO tmp_table,\n    t2 TO t1,\n    tmp_table TO t2;\n`\n\nWAIT/NOWAIT\n\nSet the lock wait timeout. See WAIT and NOWAIT.\n\nPrivileges\n\nExecuting the RENAME TABLE statement requires the DROP, CREATE and INSERT privileges for the table or the database.\n\nAtomic RENAME TABLE\n\nRENAME TABLE is atomic for most storage engines, including InnoDB, MyRocks, MyISAM and Aria (MDEV-23842).\n\nThis means that if there is a crash (server down or power outage) during RENAME TABLE, all tables revert to their original names and any changes to trigger files are reverted.\\\n\\\nSee Atomic DDL for more information.\n\nRENAME TABLE is not atomic.\n\nThere is a small chance that, during a server crash happening in the middle of RENAME TABLE`, some tables could have been renamed (in the worst case partly) while others would not be renamed.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-definition/rename-table', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-definition/rename-table');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (645, 39, 'Renaming Databases', 'Description\n-----------\n\nThere is no RENAME DATABASE statement. To rename a database, use one of the following procedures.\n\nUsing RENAME TABLE\n\nUse this procedure only if your tables have neither triggers nor views or events.\n\nTo move your tables from a database named db1 to one named db2, run these statements:\n\n``sql\nCREATE DATABASE db2;\nDo this for every table in database db1\nRENAME TABLE db1.t TO db2.t;\nWhen no table is left in database db1, optionally drop it\nDROP DATABASE db1;\n`\n\nPrivileges are neither dropped for db1, nor are they "copied" to db2. Use SHOW PRIVILEGES to see which privileges are related to db1, then apply those privileges to db2.\n\nRenaming Databases Manually\n\nTo overcome the limitations of the previous procedure, you can do the following.\n\nIn the following steps, the source database is named PROD , and the destination database TEST.\n\n* Full Backup and Restore: If restoring to a different server, use mariadb-backup to create a full backup, then restore it to the intended server. (This step is optional. It is not necessary if your renamed database is to reside on the same computer.)\n\nDump Logical Objects.\n\nRENAME TABLE does not work for triggers, events, and routines. You need to dump these logical objects separately.\n\n`bash\nmariadb-dump PROD --no-data --routines --triggers --events \\\n> PROD_routines_triggers_events.sql\n`\n\nGenerate RENAME TABLE Commands.\n\nRun the following query to generate a script with the necessary RENAME TABLE statements. This is much faster than a full logical dump.\n\n`sql\nmysql -ss -e"SELECT CONCAT(''RENAME TABLE PROD.'', TABLE_NAME, '' TO TEST.'', \\\nTABLE_NAME, '';'') FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = ''PROD''" \\\n> PROD_rename_table.sql\n`\n\nList all Existing Objects.\n\n`sql\nSELECT TABLE_SCHEMA, TABLE_NAME FROM INFORMATION_SCHEMA.TABLES \n       WHERE TABLE_SCHEMA = ''PROD'';\nSELECT EVENT_SCHEMA, EVENT_NAME FROM INFORMATION_SCHEMA.EVENTS \n       WHERE EVENT_SCHEMA = ''PROD'';\nSELECT ROUTINE_SCHEMA, ROUTINE_NAME FROM INFORMATION_SCHEMA.ROUTINES \n       WHERE ROUTINE_SCHEMA = ''PROD'';\nSELECT TRIGGER_SCHEMA, TRIGGER_NAME FROM INFORMATION_SCHEMA.TRIGGERS \n WHERE TRIGGER_SCHEMA = ''PROD'';\n`\n\nCreate the new Database.\n\n`sql\nCREATE DATABASE TEST;\n`\n\nRun the rename_table Script.\n\n`bash\nmysql TEST < PROD_rename_table.sql\n`\n\nRestore Logical Objects.\n\nAfter the rename script completes, restore the triggers, routines, and events into the new database.\n\n`bash\nmysql TEST < PROD_routines_triggers_events.sql\n`\n\nVerify all Objects are Restored.\n\nVerify that all objects have been correctly moved to the new TEST database.\n\n`sql\nSELECT TABLE_SCHEMA, TABLE_NAME FROM INFORMATION_SCHEMA.TABLES \n       WHERE TABLE_SCHEMA = ''TEST'';\nSELECT EVENT_SCHEMA, EVENT_NAME FROM INFORMATION_SCHEMA.EVENTS \n       WHERE EVENT_SCHEMA = ''TEST'';\nSELECT ROUTINE_SCHEMA, ROUTINE_NAME FROM INFORMATION_SCHEMA.ROUTINES \n       WHERE ROUTINE_SCHEMA = ''TEST'';\nSELECT TRIGGER_SCHEMA, TRIGGER_NAME FROM INFORMATION_SCHEMA.TRIGGERS \n       WHERE TRIGGER_SCHEMA = ''TEST'';\n`\n\nCleanup.\n\nOnce you have confirmed everything looks good, you can drop the old PROD database.\n\nPrivileges are neither dropped for PROD, nor are they "copied" to TEST. Use SHOW PRIVILEGES to see which privileges are related to PROD, then apply those privileges to TEST`.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-definition/renaming-databases', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-definition/renaming-databases');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (646, 27, 'DELETE', 'Syntax\n------\n\nDELETE [LOW_PRIORITY] [QUICK] [IGNORE] \n  FROM tbl_name [PARTITION (partition_list)]\n  [FOR PORTION OF PERIOD FROM expr1 TO expr2]\n  [AS alias]                    -- from MariaDB 11.6\n  [WHERE where_condition]\n  [ORDER BY ...]\n  [LIMIT row_count]\n  [RETURNING select_expr \n    [, select_expr ...]]\n\nDescription\n-----------\n\n| Option        | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |\n| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| LOW_PRIORITY | Wait until all SELECT statement are done before starting the statement. Used with storage engines that uses table locking (MyISAM, Aria etc). See HIGH_PRIORITY and LOW_PRIORITY clauses for details.                                                                                                                                                                                                                                                          |\n| QUICK         | Signal the storage engine that it should expect that a lot of rows are deleted. The storage engine can do things to speed up the DELETE like ignoring merging of data blocks until all rows are deleted from the block (instead of when a block is half full). This speeds up things at the expanse of lost space in data blocks. At least MyISAM and Aria support this feature. |\n| IGNORE        | Don''t stop the query even if a not-critical error occurs (like data overflow). See How IGNORE works for a full description.                                                                                                                                                                                                                                                                                                                                      |\n\nFor the single-table syntax, the DELETE statement deletes rows from tbl_name and returns a count of the number of deleted rows. This count can be obtained by calling the ROW_COUNT() function. TheWHERE clause, if given, specifies the conditions that identify which rows to delete. With no WHERE clause, all rows are deleted. If the ORDER BY clause is specified, the rows are deleted in the order that is specified. The LIMIT clause places a limit on the number of rows that can be deleted.\n\nFor the multiple-table syntax, DELETE deletes from each tbl_name the rows that satisfy the conditions. In this case, ORDER BY and LIMIT cannot be used. A DELETE can also reference tables which are located in different databases; see Identifier Qualifiers for the syntax.\n\nwhere_condition is an expression that evaluates to true for each row to be deleted. It is specified as described in SELECT.\n\nYou cannot delete from a table and select from the same table in a subquery.\n\nYou need the DELETE privilege on a table to delete rows from it. You need only the SELECT privilege for any columns that are only read, such as those named in the WHERE clause. See GRANT.\n\nAs stated, a DELETE statement with no WHERE clause deletes all rows. A faster way to do this, when you do not need to know the number of deleted rows, is to use TRUNCATE TABLE. However, within a transaction or if you have a lock on the table,TRUNCATE TABLE cannot be used whereas DELETE can. See TRUNCATE TABLE, and LOCK.\n\nAS\n\nSingle-table DELETE statements support aliases. For example:\n\n``sql\nCREATE TABLE t1 (c1 INT);\nINSERT INTO t1 VALUES (1), (2);\n\nDELETE FROM t1 AS a1 WHERE a1.c1 = 2;\n`\n\nSingle-table DELETE statements do not support aliases.\n\nPARTITION\n\nSee Partition Pruning and Selection for details.\n\nFOR PORTION OF\n\nSee Application Time Periods - Deletion by Portion.\n\nRETURNING\n\nIt is possible to return a result set of the deleted rows for a single table to the client by using the syntax DELETE ... RETURNING select_expr [, select_expr2 ...]]\n\nAny of SQL expression that can be calculated from a single row fields is allowed. Subqueries are allowed. The AS keyword is allowed, so it is possible to use aliases.\n\nThe use of aggregate functions is not allowed. RETURNING cannot be used in multi-table DELETE statements.\n\nSame Source and Target Table\n\nIt is possible to delete from a table with the same source and target. For example:\n\n`sql\nDELETE FROM t1 WHERE c1 IN (SELECT b.c1 FROM t1 b WHERE b.c2=0);\n`\n\nDELETE HISTORY\n\nYou can use DELETE HISTORY` to delete historical information from System-versioned tables.\n\nExamples\n--------\n\nDELETE FROM page_hit ORDER BY TIMESTAMP LIMIT 1000000;\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/changing-deleting-data/delete', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/changing-deleting-data/delete');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (647, 27, 'HIGH\\_PRIORITY and LOW\\_PRIORITY', 'Description\n-----------\n\nThe InnoDB storage engine uses row-level locking to ensure data integrity. However some storage engines (such as MEMORY, MyISAM, Aria and MERGE) lock the whole table to prevent conflicts. These storage engines use two separate queues to remember pending statements; one is for SELECTs and the other one is for write statements (INSERT, DELETE, UPDATE). By default, the latter has a higher priority.\n\nTo give write operations a lower priority, the low_priority_updates server system variable can be set to ON. The option is available on both the global and session levels, and it can be set at startup or via the SET statement.\n\nWhen too many table locks have been set by write statements, some pending SELECTs are executed. The maximum number of write locks that can be acquired before this happens is determined by the max_write_lock_count server system variable, which is dynamic.\n\nIf write statements have a higher priority (default), the priority of individual write statements (INSERT, REPLACE, UPDATE, DELETE) can be changed via the LOW_PRIORITY attribute, and the priority of a SELECT statement can be raised via the HIGH_PRIORITY attribute. Also, LOCK TABLES supports a LOW_PRIORITY attribute for WRITE locks.\n\nIf read statements have a higher priority, the priority of an INSERT can be changed via the HIGH_PRIORITY attribute. However, the priority of other write statements cannot be raised individually.\n\nThe use of LOW_PRIORITY or HIGH_PRIORITY for an INSERT prevents Concurrent Inserts from being used.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/changing-deleting-data/high_priority-and-low_priority', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/changing-deleting-data/high_priority-and-low_priority');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (648, 27, 'REPLACE', 'Syntax\n------\n\nREPLACE [LOW_PRIORITY | DELAYED]\n [INTO] tbl_name [PARTITION (partition_list)] [(col,...)]\n {VALUES | VALUE} ({expr | DEFAULT},...),(...),...\n[RETURNING select_expr \n      [, select_expr ...]]\n\nDescription\n-----------\n\nREPLACE works exactly like INSERT, except that if an old row in the table has the same value as a new row for a PRIMARY KEY or aUNIQUE index, the old row is deleted before the new row is inserted. If the table has more than one UNIQUE keys, it is possible that the new row conflicts with more than one row. In this case, all conflicting rows will be deleted.\n\nThe table name can be specified in the form db_name.tbl_name or, if a default database is selected, in the form tbl_name (see Identifier Qualifiers). This allows to use REPLACE ... SELECT to copy rows between different databases.\n\nBasically it works like this:\n\n``sql\nBEGIN;\nSELECT 1 FROM t1 WHERE KEY=# FOR UPDATE;\nIF FOUND-ROW\n  DELETE FROM t1 WHERE KEY=# ;\nENDIF\nINSERT INTO t1 VALUES (...);\nEND;\n`\n\nThe above can be replaced with:\n\n`sql\nREPLACE INTO t1 VALUES (...)\n`\n\nREPLACE is a MariaDB/MySQL extension to the SQL standard. It either inserts, or deletes and inserts. For other MariaDB/MySQL extensions to standard SQL --- that also handle duplicate values --- see IGNORE and INSERT ON DUPLICATE KEY UPDATE.\n\nNote that unless the table has a PRIMARY KEY orUNIQUE index, using a REPLACE statement makes no sense. It becomes equivalent to INSERT, because there is no index to be used to determine whether a new row duplicates another.\n\nValues for all columns are taken from the values. See Partition Pruning and Selection for details. Specified in theREPLACE statement. Any missing columns are set to their default values, just as happens for INSERT. You cannot refer to values from the current row and use them in the new row. If you use an assignment such as ''SET col = col + 1'', the reference to the column name on the right hand side is treated asDEFAULT(col), so the assignment is equivalent to''SET col = DEFAULT(col) + 1''.\n\nTo use REPLACE, you must have both theINSERT and DELETE privileges for the table.\n\nThere are some issues you should be aware of, before using REPLACE:\n\n If there is an AUTO_INCREMENT field, a new value will be generated.\n If there are foreign keys, ON DELETE action will be activated by REPLACE.\n* Triggers on DELETE and INSERT will be activated by REPLACE.\n\nTo avoid some of these behaviors, you can use INSERT ... ON DUPLICATE KEY UPDATE.\n\nThis statement activates INSERT and DELETE triggers. See Trigger Overview for details.\n\nPARTITION\n\nSee Partition Pruning and Selection for details.\n\nREPLACE RETURNING\n\nREPLACE ... RETURNING returns a resultset of the replaced rows. This returns the listed columns for all the rows that are replaced, or alternatively, the specified SELECT expression. Any SQL expressions which can be calculated can be used in the select expression for the RETURNING` clause, including virtual columns and aliases, expressions which use various operators such as bitwise, logical and arithmetic operators, string functions, date-time functions, numeric functions, control flow functions, secondary functions and stored functions. Along with this, statements which have subqueries and prepared statements can also be used.\n\nExamples\n--------\n\nREPLACE INTO t2 VALUES (1,''Leopard''),(2,''Dog'') RETURNING id2, id2+id2 \nas Total ,id2|id2, id2&&id2;\n+-----+-------+---------+----------+\n| id2 | Total | id2|id2 | id2&&id2 |\n+-----+-------+---------+----------+\n|   1 |     2 |       1 |        1 |\n|   2 |     4 |       2 |        1 |\n+-----+-------+---------+----------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/changing-deleting-data/replace', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/changing-deleting-data/replace');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (649, 27, 'REPLACE...RETURNING', 'Syntax\n------\n\nREPLACE [LOW_PRIORITY | DELAYED]\n [INTO] tbl_name [PARTITION (partition_list)] [(col,...)]\n {VALUES | VALUE} ({expr | DEFAULT},...),(...),...\n[RETURNING select_expr \n      [, select_expr ...]]\n\nDescription\n-----------\n\nREPLACE ... RETURNING returns a result set of the replaced rows. The statement returns the listed columns for all the rows that are replaced, or alternatively, the specified SELECT expression. Any SQL expressions which can be calculated can be used in the select expression for the RETURNING clause, including virtual columns and aliases, expressions which use various operators such as bitwise, logical and arithmetic operators, string functions, date-time functions, numeric functions, control flow functions, secondary functions and stored functions. Along with this, statements which have subqueries and prepared statements can also be used.\n\nExamples\n--------\n\nREPLACE INTO t2 VALUES (1,''Leopard''),(2,''Dog'') RETURNING id2, id2+id2 \nAS Total ,id2|id2, id2&&id2;\n+-----+-------+---------+----------+\n| id2 | Total | id2|id2 | id2&&id2 |\n+-----+-------+---------+----------+\n|   1 |     2 |       1 |        1 |\n|   2 |     4 |       2 |        1 |\n+-----+-------+---------+----------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/changing-deleting-data/replacereturning', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/changing-deleting-data/replacereturning');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (650, 27, 'UPDATE', 'Syntax\n------\n\nUPDATE [LOW_PRIORITY] [IGNORE] table_reference \n  [PARTITION (partition_list)]\n  [FOR PORTION OF period FROM expr1 TO expr2]\n  SET col1={expr1|DEFAULT} [,col2={expr2|DEFAULT}] ...\n  [WHERE where_condition]\n  [ORDER BY ...]\n  [LIMIT row_count]\n  RETURNING OLD_VALUE(val) AS old [, val as new]\n\nDescription\n-----------\n\nFor the single-table syntax, the UPDATE statement updates columns of existing rows in the named table with new values. TheSET clause indicates which columns to modify and the values they should be given. Each value can be given as an expression, or the keywordDEFAULT to set a column explicitly to its default value. TheWHERE clause, if given, specifies the conditions that identify which rows to update. With no WHERE clause, all rows are updated. If the ORDER BY clause is specified, the rows are\\\nupdated in the order that is specified. The LIMIT clause places a limit on the number of rows that can be updated.\n\nBoth clauses can be used with multiple-table updates.\n\nBoth clauses can be used with multiple-table updates. For the multiple-table syntax, UPDATE updates rows in each table named in table_references that satisfy the conditions. In this case, ORDER BY and LIMIT could not be used.\n\nAn UPDATE can also reference tables which are located in different databases; see Identifier Qualifiers for the syntax.\n\nwhere_condition is an expression that evaluates to true for each row to be updated.\n\ntable_references and where_condition are as specified as described in SELECT.\n\nFor single-table updates, assignments are evaluated in left-to-right order, while for multi-table updates, there is no guarantee of a particular order. If the SIMULTANEOUS_ASSIGNMENT sql_mode is set, UPDATE statements evaluate all assignments simultaneously.\n\nYou need the UPDATE privilege only for columns referenced in an UPDATE that are actually updated. You need only the SELECT privilege for any columns that are read but not modified. See GRANT.\n\nThe UPDATE statement supports the following modifiers:\n\n If you use the LOW_PRIORITY keyword, execution of the UPDATE is delayed until no other clients are reading from the table. This affects only storage engines that use only table-level locking (MyISAM, MEMORY, MERGE). See HIGH_PRIORITY and LOW_PRIORITY clauses for details.\n If you use the IGNORE keyword, the update statement does not abort even if errors occur during the update. Rows for which duplicate-key conflicts occur are not updated. Rows for which columns are updated to values that would cause data conversion errors are updated to the closest valid values instead.\n\nPARTITION\n\nSee Partition Pruning and Selection for details.\n\nFOR PORTION OF\n\nSee Application Time Periods - Updating by Portion.\n\nUPDATE Statements With the Same Source and Target\n\nUPDATE statements may have the same source and target. For example, given the following table:\n\n``sql\nDROP TABLE t1;\nCREATE TABLE t1 (c1 INT, c2 INT);\nINSERT INTO t1 VALUES (10,10), (20,20);\n\nUPDATE t1 SET c1=c1+1 WHERE c2=(SELECT MAX(c2) FROM t1);\n\nSELECT * FROM t1;\n+------+------+\n| c1   | c2   |\n+------+------+\n|   10 |   10 |\n|   21 |   20 |\n+------+------+\n``\n\nExamples\n--------\n\nUPDATE table_name SET column1 = value1, column2 = value2 WHERE id=100;\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/changing-deleting-data/update', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/changing-deleting-data/update');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (651, 27, 'Concurrent Inserts', 'Description\n-----------\n\nThe MyISAM storage engine supports concurrent inserts. This feature allows SELECT statements to be executed during INSERT operations, reducing contention.\n\nWhether concurrent inserts can be used or not depends on the value of the concurrent_insert server system variable:\n\n NEVER (0) disables concurrent inserts.\n AUTO (1) allows concurrent inserts only when the target table has no free blocks (no data in the middle of the table has been deleted after the last OPTIMIZE TABLE). This is the default.\n* ALWAYS (2) always enables concurrent inserts, in which case new rows are added at the end of a table if the table is being used by another thread.\n\nIf the binary log is used, CREATE TABLE ... SELECT and INSERT ... SELECT statements cannot use concurrent inserts. These statements acquire a read lock on the table, so concurrent inserts will need to wait. This way, the log can be safely used to restore data.\n\nConcurrent inserts are not used by slaves with the row-based replication (see binary log formats).\n\nIf an INSERT statement contains the HIGH_PRIORITY clause, concurrent inserts cannot be used. INSERT ... DELAYED is usually unneeded if concurrent inserts are enabled.\n\nLOAD DATA INFILE uses concurrent inserts if the CONCURRENT keyword is specified and concurrent_insert is not NEVER. This makes the statement slower (even if no other sessions access the table) but reduces contention.\n\nLOCK TABLES allows non-conflicting concurrent inserts if a READ LOCAL lock is used. Concurrent inserts are not allowed if the LOCAL keyword is omitted.\n\nNotes\n\nThe decision to enable concurrent insert for a table is done when the table is opened. If you change the value of concurrent_insert, it will only affect newly opened tables. If you want it to work for also for tables in use or cached, you should do FLUSH TABLES after setting the variable.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/inserting-loading-data/concurrent-inserts', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/inserting-loading-data/concurrent-inserts');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (652, 27, 'IGNORE', 'Description\n-----------\n\nThe IGNORE option tells the server to ignore some common errors.\n\nIGNORE can be used with the following statements:\n\n DELETE\n INSERT (see also INSERT IGNORE)\n LOAD DATA INFILE\n UPDATE\n ALTER TABLE\n CREATE TABLE ... SELECT\n INSERT ... SELECT\n\nThe logic used:\n\n Variables out of ranges are replaced with the maximum/minimum value.\n SQL_MODEs STRICT_TRANS_TABLES, STRICT_ALL_TABLES, NO_ZERO_IN_DATE, NO_ZERO_DATE are ignored.\n Inserting NULL in a NOT NULL field will insert 0 ( in a numerical field), 0000-00-00 ( in a date field) or an empty string ( in a character field).\n* Rows that cause a duplicate key error or break a foreign key constraint are not inserted, updated, or deleted.\n\nThe following errors are ignored:\n\n| Error number | Symbolic error name                              | Description                                                           |\n| ------------ | ------------------------------------------------ | --------------------------------------------------------------------- |\n| 1022         | ER_DUP_KEY                                     | Can''t write; duplicate key in table ''%s''                              |\n| 1048         | ER_BAD_NULL_ERROR                             | Column ''%s'' cannot be null                                            |\n| 1062         | ER_DUP_ENTRY                                   | Duplicate entry ''%s'' for key %d                                       |\n| 1242         | ER_SUBQUERY_NO_1_ROW                         | Subquery returns more than 1 row                                      |\n| 1264         | ER_WARN_DATA_OUT_OF_RANGE                   | Out of range value for column ''%s'' at row %ld                         |\n| 1265         | WARN_DATA_TRUNCATED                            | Data truncated for column ''%s'' at row %ld                             |\n| 1292         | ER_TRUNCATED_WRONG_VALUE                      | Truncated incorrect %s value: ''%s''                                    |\n| 1366         | ER_TRUNCATED_WRONG_VALUE_FOR_FIELD          | Incorrect integer value                                               |\n| 1369         | ER_VIEW_CHECK_FAILED                          | CHECK OPTION failed ''%s.%s''                                           |\n| 1451         | ER_ROW_IS_REFERENCED_2                       | Cannot delete or update a parent row                                  |\n| 1452         | ER_NO_REFERENCED_ROW_2                       | Cannot add or update a child row: a foreign key constraint fails (%s) |\n| 1526         | ER_NO_PARTITION_FOR_GIVEN_VALUE             | Table has no partition for value %s                                   |\n| 1586         | ER_DUP_ENTRY_WITH_KEY_NAME                  | Duplicate entry ''%s'' for key ''%s''                                     |\n| 1591         | ER_NO_PARTITION_FOR_GIVEN_VALUE_SILENT     | Table has no partition for some existing values                       |\n| 1748         | ER_ROW_DOES_NOT_MATCH_GIVEN_PARTITION_SET | Found a row not matching the given partition set                      |\n\nIgnored errors normally generate a warning.\n\nA property of the IGNORE clause consists in causing transactional engines and non-transactional engines (like InnoDB and Aria) to behave the same way. For example, normally a multi-row insert which tries to violate a UNIQUE contraint is completely rolled back on InnoDB, but might be partially executed on Aria. With the IGNORE clause, the statement will be partially executed in both engines.\n\nDuplicate key errors also generate warnings. The OLD_MODE server variable can be used to prevent this.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/inserting-loading-data/ignore', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/inserting-loading-data/ignore');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (653, 27, 'INSERT - Default & Duplicate Values', 'Description\n-----------\n\nDefault Values\n\nIf the SQL_MODE contains STRICT_TRANS_TABLES and you are inserting into a transactional table (like InnoDB), or if the SQL_MODE contains STRICT_ALL_TABLES, all NOT NULL columns which do not have a DEFAULT value (and are not AUTO_INCREMENT) must be explicitly referenced in INSERT statements. If not, an error like this is produced:\n\n``\nERROR 1364 (HY000): Field ''col'' doesn''t have a default value\n`\n\nIn all other cases, if a NOT NULL column without a DEFAULT value is not referenced, an empty value will be inserted (for example, 0 for INTEGER columns and '''' for CHAR columns). See NULL Values in MariaDB:Inserting for examples.\n\nIf a NOT NULL column having a DEFAULT value is not referenced, NULL will be inserted.\n\nIf a NULL column having a DEFAULT value is not referenced, its default value will be inserted. It is also possible to explicitly assign the default value using the DEFAULT keyword or the DEFAULT() function.\n\nIf the DEFAULT keyword is used but the column does not have a DEFAULT value, an error like this is produced:\n\n`\nERROR 1364 (HY000): Field ''col'' doesn''t have a default value\n`\n\nDuplicate Values\n\nBy default, if you try to insert a duplicate row and there is a UNIQUE index, INSERT stops and an error like this is produced:\n\n`\nERROR 1062 (23000): Duplicate entry ''dup_value'' for key ''col''\n``\n\nTo handle duplicates you can use the IGNORE clause, INSERT ON DUPLICATE KEY UPDATE or the REPLACE statement. Note that the IGNORE and DELAYED options are ignored when you use ON DUPLICATE KEY UPDATE.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/inserting-loading-data/insert-default-duplicate-values', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/inserting-loading-data/insert-default-duplicate-values');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (654, 27, 'INSERT DELAYED', 'Description\n-----------\n\nThe DELAYED option for the INSERT statement is a MariaDB/MySQL extension to standard SQL that is very useful if you have clients that cannot or need not wait for the INSERT to complete. This is a common situation when you use MariaDB for logging and you also periodically run SELECT and UPDATE statements that take a long time to complete.\n\nWhen a client uses INSERT DELAYED, it gets an okay from the server at once, and the row is queued to be inserted when the table is not in use by any other thread.\n\nAnother major benefit of using INSERT DELAYED is that inserts from many clients are bundled together and written in one block. This is much faster than performing many separate inserts.\n\nNote that INSERT DELAYED is slower than a normalINSERT if the table is not otherwise in use. There is also the additional overhead for the server to handle a separate thread for each table for which there are delayed rows. This means that you should useINSERT DELAYED only when you are really sure that you need it.\n\nThe queued rows are held only in memory until they are inserted into the table. This means that if you terminate mariadbd forcibly (for example, with kill -9) or if mariadbd dies unexpectedly, any queued rows that have not been written to disk are lost.\n\nThe number of concurrent INSERT DELAYED threads is limited by the max_delayed_threads server system variables. If it is set to 0, INSERT DELAYED is disabled. The session value can be equal to the global value, or 0 to disable this statement for the current session. If this limit has been reached, the DELAYED clause will be silently ignore for subsequent statements (no error will be produced).\n\nLimitations\n\nThere are some limitations on the use of DELAYED:\n\n INSERT DELAYED works only with MyISAM, MEMORY, ARCHIVE,\\\n  and BLACKHOLE tables. If you execute INSERT DELAYED with another storage engine, you will get an error like this: ERROR 1616 (HY000): DELAYED option not supported for table ''tab_name''\n For MyISAM tables, if there are no free blocks in the middle of the data file, concurrent SELECT and INSERT statements are supported. Under these circumstances, you very seldom need to use INSERT DELAYED with MyISAM.\n INSERT DELAYED should be used only forINSERT statements that specify value lists. The server\\\n  ignores DELAYED for INSERT ... SELECT or INSERT ... ON DUPLICATE KEY UPDATE statements.\n Because the INSERT DELAYED statement returns immediately, before the rows are inserted, you cannot useLAST_INSERT_ID() to get theAUTO_INCREMENT value that the statement might generate.\n DELAYED rows are not visible to SELECT statements until they actually have been inserted.\n After INSERT DELAYED, ROW_COUNT() returns the number of the rows you tried to insert, not the number of the successful writes.\n DELAYED is ignored on slave replication servers, so thatINSERT DELAYED is treated as a normal INSERT on slaves. This is becauseDELAYED could cause the slave to have different data than\\\n  the master. INSERT DELAYED statements are not safe for replication.\n Pending INSERT DELAYED statements are lost if a table is write locked and ALTER TABLE is used to modify the table structure.\n INSERT DELAYED is not supported for views. If you try, you will get an error like this: ERROR 1347 (HY000): ''view_name'' is not BASE TABLE\n INSERT DELAYED is not supported for partitioned tables.\n INSERT DELAYED is not supported within stored programs.\n INSERT DELAYED does not work with triggers.\n INSERT DELAYED does not work if there is a check constraint in place.\n INSERT DELAYED does not work if skip-new mode is active.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/inserting-loading-data/insert-delayed', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/inserting-loading-data/insert-delayed');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (655, 27, 'INSERT IGNORE', 'Description\n-----------\n\nIgnoring Errors\n\nNormally INSERT stops and rolls back when it encounters an error.\n\nBy using the IGNORE keyword all errors are converted to warnings, which will not stop inserts of additional rows.\n\nInvalid values are changed to the closest valid value and inserted, with a warning produced.\n\nThe IGNORE and DELAYED options are ignored when you use ON DUPLICATE KEY UPDATE.\n\nWarnings are issued for duplicate key errors when using IGNORE. You can get the old behavior if you set OLD_MODE to NO_DUP_KEY_WARNINGS_WITH_IGNORE.\n\nNo warnings are issued for duplicate key errors when using IGNORE.\n\nSee IGNORE for a full description of effects.\n\nExamples\n--------\n\nCREATE TABLE t1 (x INT UNIQUE);\n\nINSERT INTO t1 VALUES(1),(2);\n\nINSERT INTO t1 VALUES(2),(3);\nERROR 1062 (23000): Duplicate entry ''2'' for key ''x''\nSELECT  FROM t1;\n+------+\n| x    |\n+------+\n|    1 |\n|    2 |\n+------+\n\nINSERT IGNORE INTO t1 VALUES(2),(3);\nQuery OK, 1 row affected, 1 warning (0.04 sec)\n\nSHOW WARNINGS;\n+---------+------+---------------------------------+\n| Level   | Code | Message                         |\n+---------+------+---------------------------------+\n| Warning | 1062 | Duplicate entry ''2'' for key ''x'' |\n+---------+------+---------------------------------+\n\nSELECT  FROM t1;\n+------+\n| x    |\n+------+\n|    1 |\n|    2 |\n|    3 |\n+------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/inserting-loading-data/insert-ignore', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/inserting-loading-data/insert-ignore');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (656, 27, 'INSERT ON DUPLICATE KEY UPDATE', 'Syntax\n------\n\nINSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE]\n  [INTO] tbl_name [PARTITION (partition_list)] [(col,...)]\n  {VALUES | VALUE} ({expr | DEFAULT},...),(...),...\n  [ ON DUPLICATE KEY UPDATE\n    col=expr\n      [, col=expr] ... ]\n\nDescription\n-----------\n\nINSERT ... ON DUPLICATE KEY UPDATE (often called "upsert") is a MariaDB/MySQL extension to the INSERT statement that, if it finds a duplicate unique or primary key, will instead perform an UPDATE.\n\nThe row/s affected value is reported as 1 if a row is inserted, and 2 if a row is updated, unless the API''s CLIENT_FOUND_ROWS flag is set.\n\nIf more than one unique index is matched, only the first is updated. It is not recommended to use this statement on tables with more than one unique index.\n\nIf the table has an AUTO_INCREMENT primary key and the statement inserts or updates a row, the LAST_INSERT_ID() function returns its AUTO_INCREMENT value.\n\nThe VALUES() function can only be used in a ON DUPLICATE KEY UPDATE clause and has no meaning in any other context. It returns the column values from the INSERT portion of the statement. This function is particularly useful for multi-rows inserts.\n\nThe IGNORE and DELAYED options are ignored when you use ON DUPLICATE KEY UPDATE.\n\nSee Partition Pruning and Selection for details on the PARTITION clause.\n\nThis statement activates INSERT and UPDATE triggers. See Trigger Overview for details.\n\nSee also a similar statement, REPLACE.\n\nExamples\n--------\n\nCREATE TABLE ins_duplicate (id INT PRIMARY KEY, animal VARCHAR(30));\nINSERT INTO ins_duplicate VALUES (1,''Aardvark''), (2,''Cheetah''), (3,''Zebra'');\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/inserting-loading-data/insert-on-duplicate-key-update', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/inserting-loading-data/insert-on-duplicate-key-update');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (657, 27, 'INSERT SELECT', 'Syntax\n------\n\nINSERT [LOW_PRIORITY | HIGH_PRIORITY] [IGNORE]\n    [INTO] tbl_name [(col_name,...)]\n    SELECT ...\n    [ ON DUPLICATE KEY UPDATE col_name=expr, ... ]\n\nDescription\n-----------\n\nWith INSERT ... SELECT, you can quickly insert many rows into a table from one or more other tables. For example:\n\n``sql\nINSERT INTO tbl_temp2 (fld_id)\n  SELECT tbl_temp1.fld_order_id\n  FROM tbl_temp1 WHERE tbl_temp1.fld_order_id > 100;\n`\n\ntbl_name can also be specified in the form db_name.tbl_name (see Identifier Qualifiers). This allows to copy rows between different databases.\n\nIf the new table has a primary key or UNIQUE indexes, you can use IGNORE to handle duplicate key errors during the query. The newer values will not be inserted if an identical value already exists.\n\nREPLACE can be used instead of INSERT to prevent duplicates on UNIQUE indexes by deleting old values. In that case, ON DUPLICATE KEY UPDATE cannot be used.\n\nINSERT ... SELECT` works for tables which already exist. To create a table for a given resultset, you can use CREATE TABLE ... SELECT.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/inserting-loading-data/insert-select', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/inserting-loading-data/insert-select');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (658, 27, 'INSERT', 'Description\n-----------\n\nSyntax\n\n``sql\nINSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE]\n [INTO] tbl_name [PARTITION (partition_list)] [(col,...)]\n {VALUES | VALUE} ({expr | DEFAULT},...),(...),...\n [ ON DUPLICATE KEY UPDATE\n   col=expr\n     [, col=expr] ... ] [RETURNING select_expr \n      [, select_expr ...]]\n`\n\nOr:\n\n`sql\nINSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE]\n    [INTO] tbl_name [PARTITION (partition_list)]\n    SET col={expr | DEFAULT}, ...\n    [ ON DUPLICATE KEY UPDATE\n      col=expr\n        [, col=expr] ... ] [RETURNING select_expr \n      [, select_expr ...]]\n`\n\nOr:\n\n`sql\nINSERT [LOW_PRIORITY | HIGH_PRIORITY] [IGNORE]\n    [INTO] tbl_name [PARTITION (partition_list)] [(col,...)]\n    SELECT ...\n    [ ON DUPLICATE KEY UPDATE\n      col=expr\n        [, col=expr] ... ] [RETURNING select_expr \n      [, select_expr ...]]\n`\n\nThe INSERT statement is used to insert new rows into an existing table. The INSERT ... VALUES\\\nand INSERT ... SET forms of the statement insert rows based on explicitly specified values. The INSERT ... SELECT form inserts rows selected from another table or tables. INSERT ... SELECT is discussed further in the INSERT ... SELECT article.\n\nThe table name can be specified in the form db_name.tbl_name or, if a default database is selected, in the form tbl_name (see Identifier Qualifiers). This allows to use INSERT ... SELECT to copy rows between different databases.\n\nThe PARTITION clause can be used in both the INSERT and the SELECT part. See Partition Pruning and Selection for details.\n\nThe RETURNING clause can be used.\n\nThe RETURNING clause is not available.\n\nThe columns list is optional. It specifies which values are explicitly inserted, and in which order. If this clause is not specified, all values must be explicitly specified, in the same order they are listed in the table definition.\n\nThe list of value follow the VALUES or VALUE keyword (which are interchangeable, regardless how much values you want to insert), and is wrapped by parenthesis. The values must be listed in the same order as the columns list. It is possible to specify more than one list to insert more than one rows with a single statement. If many rows are inserted, this is a speed optimization.\n\nFor one-row statements, the SET clause may be more simple, because you don''t need to remember the columns order. All values are specified in the form col = expr.\n\nValues can also be specified in the form of a SQL expression or subquery. However, the subquery cannot access the same table that is named in the INTO clause.\n\nIf you use the LOW_PRIORITY keyword, execution of the INSERT is delayed until no other clients are reading from the table. If you use the HIGH_PRIORITY keyword, the statement has the same priority as SELECTs. This affects only storage engines that use only table-level locking (MyISAM, MEMORY, MERGE). However, if one of these keywords is specified, concurrent inserts cannot be used. See HIGH_PRIORITY and LOW_PRIORITY clauses for details.\n\nINSERT DELAYED\n\nFor more details on the DELAYED` option, see INSERT DELAYED.\n\nHIGH PRIORITY and LOW PRIORITY\n\nSee HIGH_PRIORITY and LOW_PRIORITY.\n\nDefaults and Duplicate Values\n\nSee INSERT - Default & Duplicate Values for details..\n\nINSERT IGNORE\n\nSee INSERT IGNORE.\n\nINSERT ON DUPLICATE KEY UPDATE\n\nSee INSERT ON DUPLICATE KEY UPDATE.\n\nExamples\n--------\n\nINSERT INTO person (first_name, last_name) VALUES (''John'', ''Doe'');\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/inserting-loading-data/insert', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/inserting-loading-data/insert');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (659, 27, 'INSERT...RETURNING', 'Syntax\n------\n\nINSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE]\n [INTO] tbl_name [PARTITION (partition_list)] [(col,...)]\n {VALUES | VALUE} ({expr | DEFAULT},...),(...),...\n [ ON DUPLICATE KEY UPDATE\n   col=expr\n     [, col=expr] ... ] [RETURNING select_expr \n      [, select_expr ...]]\n\nDescription\n-----------\n\nINSERT ... RETURNING returns a resultset of the inserted rows.\n\nIt returns the listed columns for all the rows that are inserted, or alternatively, the specified SELECT expression. Any SQL expressions which can be calculated can be used in the select expression for the RETURNING clause, including virtual columns and aliases, expressions which use various operators such as bitwise, logical and arithmetic operators, string functions, date-time functions, numeric functions, control flow functions, secondary functions and stored functions. Along with this, statements which have subqueries and prepared statements can also be used.\n\nExamples\n--------\n\nCREATE OR REPLACE TABLE t2 (id INT, animal VARCHAR(20), t TIMESTAMP);\n\nINSERT INTO t2 (id) VALUES (2),(3) RETURNING id,t;\n+------+---------------------+\n| id   | t                   |\n+------+---------------------+\n|    2 | 2021-04-28 00:59:32 |\n|    3 | 2021-04-28 00:59:32 |\n+------+---------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/inserting-loading-data/insertreturning', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/inserting-loading-data/insertreturning');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (660, 27, 'LOAD DATA INFILE', 'Syntax\n------\n\nLOAD DATA [LOW_PRIORITY | CONCURRENT] [LOCAL] INFILE ''file_name''\n    [REPLACE | IGNORE]\n    INTO TABLE tbl_name\n    [CHARACTER SET charset_name]\n    [{FIELDS | COLUMNS}\n        [TERMINATED BY ''string'']\n        [[OPTIONALLY] ENCLOSED BY ''CHAR'']\n        [ESCAPED BY ''CHAR'']\n    ]\n    [LINES\n        [STARTING BY ''string'']\n        [TERMINATED BY ''string'']\n    ]\n    [IGNORE number {LINES|ROWS}]\n    [(col_name_or_user_var,...)]\n    [SET col_name = expr,...]\n\nDescription\n-----------\n\nLOAD DATA INFILE is unsafe for statement-based replication.\n\nReads rows from a text file into the designated table on the database at a very high speed. The file name must be given as a literal string.\n\nFiles are written to disk using the SELECT INTO OUTFILE statement. You can then read the files back into a table using the LOAD DATA INFILE statement. The FIELDS and LINES clauses are the same in both statements and by default fields are expected to be terminated with tabs () and lines with newlines (). These clauses are optional, but if both are specified then the FIELDS clause must precede LINES.\n\nExecuting this statement activates INSERT triggers.\n\nOne must have the FILE privilege to be able to execute LOAD DATA INFILE. This is to ensure normal users cannot read system files. LOAD DATA LOCAL INFILE does not have this requirement.\n\nIf the secure_file_priv system variable is set (by default it is not), the loaded file must be present in the specified directory.\n\nNote that MariaDB''s systemd unit file restricts access to /home, /root, and /run/user by default. See Configuring access to home directories.\n\nLOAD DATA LOCAL INFILE\n\nWhen you execute the LOAD DATA INFILE statement, MariaDB Server attempts to read the input file from its own file system. By contrast, when you execute the LOAD DATA LOCAL INFILE statement, the client attempts to read the input file from its file system, and it sends the contents of the input file to the MariaDB Server. This allows you to load files from the client''s local file system into the database.\n\nIf you don''t want to permit this operation (perhaps for security reasons), you can disable the LOAD DATA LOCAL INFILE statement on either the server or the client.\n\n The LOAD DATA LOCAL INFILE statement can be disabled on the server by setting the local_infile system variable to 0.\n The LOAD DATA LOCAL INFILE statement can be disabled on the client. If you are using MariaDB Connector/C, this can be done by unsetting the CLIENT_LOCAL_FILES capability flag with the mysql_real_connect function or by unsetting the MYSQL_OPT_LOCAL_INFILE option with mysql_optionsv function. If you are using a different client or client library, then see the documentation for your specific client or client library to determine how it handles the LOAD DATA LOCAL INFILE statement.\n The LOAD DATA LOCAL INFILE strict modes like STRICT_TRANS_TABLES are disabled with keyword "local". (MDEV-11235)\n\nIf the LOAD DATA LOCAL INFILE statement is disabled by either the server or the client and if the user attempts to execute it, then the server will cause the statement to fail with the following error message:\n\n``\nThe used command is not allowed with this MariaDB version\n`\n\nNote that it is not entirely accurate to say that the MariaDB version does not support the command. It would be more accurate to say that the MariaDB configuration does not support the command. See MDEV-20500 for more information.\n\nFrom MariaDB 10.5.2, the error message is more accurate:\n\n`\nThe used command is not allowed because the MariaDB server or client \n  has disabled the local infile capability\n`\n\nREPLACE and IGNORE\n\nIf you load data from a file into a table that already contains data and has a primary key, you may encounter issues where the statement attempts to insert a row with a primary key that already exists. When this happens, the statement fails with Error 1064, protecting the data already on the table. If you want MariaDB to overwrite duplicates, use the REPLACE keyword.\n\nThe REPLACE keyword works like the REPLACE statement. Here, the statement attempts to load the data from the file. If the row does not exist, it adds it to the table. If the row contains an existing primary key, it replaces the table data. That is, in the event of a conflict, it assumes the file contains the desired row.\n\nThis operation can cause a degradation in load speed by a factor of 20 or more if the part that has already been loaded is larger than the capacity of the InnoDB Buffer Pool. This happens because it causes a lot of turnaround in the buffer pool.\n\nUse the IGNORE keyword when you want to skip any rows that contain a conflicting primary key. Here, the statement attempts to load the data from the file. If the row does not exist, it adds it to the table. If the row contains an existing primary key, it ignores the addition request and moves on to the next. That is, in the event of a conflict, it assumes the table contains the desired row.\n\nIGNORE number {LINES|ROWS}\n\nThe IGNORE number LINES syntax can be used to ignore a number of rows from the beginning of the file. Most often this is needed when the file starts with one row that includes the column headings.\n\nCharacter Sets\n\nWhen the statement opens the file, it attempts to read the contents using the default character-set, as defined by the character_set_database system variable.\n\nIn the cases where the file was written using a character-set other than the default, you can specify the character-set to use with the CHARACTER SET clause in the statement. It ignores character-sets specified by the SET NAMES statement and by the character_set_client system variable. Setting the CHARACTER SET clause to a value of binary indicates "no conversion."\n\nThe statement interprets all fields in the file as having the same character-set, regardless of the column data type. To properly interpret file contents, you must ensure that it was written with the correct character-set. If you write a data file with mariadb-dump -T or with the SELECT INTO OUTFILE statement with the mariadb client, be sure to use the --default-character-set option, so that the output is written with the desired character-set.\n\nWhen using mixed character sets, use the CHARACTER SET clause in both SELECT INTO OUTFILE and LOAD DATA INFILE to ensure that MariaDB correctly interprets the escape sequences.\n\nThe character_set_filesystem system variable controls the interpretation of the filename.\\\nIt is currently not possible to load data files that use the ucs2 character set.\n\nPreprocessing Inputs\n\n_col_name_or_user_var_ can be a column name, or a user variable. In the case of a variable, the SET statement can be used to preprocess the value before loading into the table.\n\nPriority and Concurrency\n\nIn storage engines that perform table-level locking (MyISAM, MEMORY and MERGE), using the LOW_PRIORITY keyword, MariaDB delays insertions until no other clients are reading from the table. Alternatively, when using the MyISAM storage engine, you can use the CONCURRENT keyword to perform concurrent insertion.\n\nThe LOW_PRIORITY and CONCURRENT keywords are mutually exclusive. They cannot be used in the same statement.\n\nProgress Reporting\n\nThe LOAD DATA INFILE statement supports progress reporting. You may find this useful when dealing with long-running operations. Using another client you can issue a SHOW PROCESSLIST query to check the progress of the data load.\n\nUsing mariadb-import\n\nMariaDB ships with a separate utility for loading data from files: mariadb-import. It operates by sending LOAD DATA INFILE statements to the server.\n\nMariaDB ships with a separate utility for loading data from files: mysqlimport . It operates by sending LOAD DATA INFILE statements to the server.\n\nUsing mariadb-import you can compress the file using the --compress option, to get better performance over slow networks, providing both the client and server support the compressed protocol. Use the --local option to load from the local file system.\n\nIndexing\n\nIn cases where the storage engine supports ALTER TABLE... DISABLE KEYS statements (MyISAM and Aria), the LOAD DATA INFILE` statement automatically disables indexes during the execution.\n\nExamples\n--------\n\nCREATE TABLE t1 (a INT, b INT, c INT, d INT, PRIMARY KEY (a));\nLOAD DATA LOCAL INFILE \n ''/tmp/loaddata7.dat'' INTO TABLE t1 FIELDS TERMINATED BY '','' (a,b) SET c=a+b;\nSELECT  FROM t1;\n+------+------+------+\n| a    | b    | c    |\n+------+------+------+\n|    2 |    2 |    4 |\n|    3 |    3 |    6 |\n|    4 |    4 |    8 |\n|    5 |    5 |   10 |\n|    6 |    8 |   14 |\n+------+------+------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/inserting-loading-data/load-data-into-tables-or-index/load-data-infile', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/inserting-loading-data/load-data-into-tables-or-index/load-data-infile');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (661, 27, 'LOAD INDEX', 'Syntax\n------\n\nLOAD INDEX INTO CACHE\n  tbl_index_list [, tbl_index_list] ...\n\ntbl_index_list:\n  tbl_name\n    [[INDEX|KEY] (index_name[, index_name] ...)]\n    [IGNORE LEAVES]\n\nDescription\n-----------\n\nThe LOAD INDEX INTO CACHE statement preloads a table index into the key cache to which it has been assigned by an explicit CACHE INDEX statement, or into the default key cache otherwise.LOAD INDEX INTO CACHE is used only for MyISAM or Aria tables.\n\nThe IGNORE LEAVES modifier causes only blocks for the nonleaf nodes of the index to be preloaded.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/inserting-loading-data/load-data-into-tables-or-index/load-index', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/inserting-loading-data/load-data-into-tables-or-index/load-index');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (662, 27, 'LOAD XML', 'Syntax\n------\n\nLOAD XML [LOW_PRIORITY | CONCURRENT] [LOCAL] INFILE ''file_name''\n    [REPLACE | IGNORE]\n    INTO TABLE [db_name.]tbl_name\n    [CHARACTER SET charset_name]\n    [ROWS IDENTIFIED BY ''<tagname>'']\n    [IGNORE number {LINES | ROWS}]\n    [(column_or_user_var,...)]\n    [SET col_name = expr,...]\n\nDescription\n-----------\n\nThe LOAD XML statement reads data from an XML file into a table. Thefile_name must be given as a literal string. The tagname in the optional ROWS IDENTIFIED BY clause must also be given as a literal\\\nstring, and must be surrounded by angle brackets (< and >).\n\nLOAD XML acts as the complement of running the mariadb client in XML output mode (that is, starting the client with the --xml option). To write data from a table to an XML file, use a command such as the\\\nfollowing one from the system shell:\n\n``bash\nshell> mariadb --xml -e ''SELECT  FROM mytable'' > file.xml\n`\n\nTo read the file back into a table, use LOAD XML INFILE. By default, the element is considered to be the equivalent of a database table row; this can be changed using the ROWS IDENTIFIED BY clause.\n\nThis statement supports three different XML formats:\n\n Column names as attributes and column values as attribute values:\n\n`xml\n<row column1="value1" column2="value2" .../>\n`\n\n Column names as tags and column values as the content of these tags:\n\n`xml\n<row>\n  <column1>value1</column1>\n  <column2>value2</column2>\n</row>\n`\n\n Column names are the name attributes of tags, and values are\\\n  the contents of these tags:\n\n`xml\n<row>\n  <field name=''column1''>value1</field>\n  <field name=''column2''>value2</field>\n</row>\n`\n\nThis is the format used by other tools, such as mariadb-dump.\n\nAll 3 formats can be used in the same XML file; the import routine automatically detects the format for each row and interprets it correctly. Tags are matched based on the tag or attribute name and the\\\ncolumn name.\n\nThe following clauses work essentially the same way for LOAD XML as they do for LOAD DATA:\n\n LOW_PRIORITY or CONCURRENT\n LOCAL\n REPLACE or IGNORE\n CHARACTER SET\n (column_or_user_var,...)\n SET\n\nSee LOAD DATA for more information about these clauses.\n\nThe IGNORE number LINES or IGNORE number ROWS clause causes the first number rows in the XML file to be skipped. It is analogous to the LOAD DATA statement''s IGNORE ... LINES clause.\n\nIf the LOW_PRIORITY keyword is used, insertions are delayed until no other clients are reading from the table. The CONCURRENT keyword allows the use of concurrent inserts. These clauses cannot be specified together.\n\nThis statement activates INSERT` triggers.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/inserting-loading-data/load-data-into-tables-or-index/load-xml', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/inserting-loading-data/load-data-into-tables-or-index/load-xml');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (663, 27, 'Non-Recursive Common Table Expressions Overview', 'Description\n-----------\n\nCommon Table Expressions (CTEs) are a standard SQL feature, and are essentially temporary named result sets. There are two kinds of CTEs: Non-Recursive, which this article covers; and Recursive.\n\nNon-Recursive CTEs\n\nThe WITH keyword signifies a CTE. It is given a name, followed by a body (the main query).\n\nCTEs are similar to derived tables:\n\n``sql\nWITH engineers AS \n   ( SELECT  FROM employees\n     WHERE dept = ''Engineering'' )\n\nSELECT  FROM engineers\nWHERE ...\n`\n\n`sql\nSELECT  FROM\n   ( SELECT  FROM employees\n     WHERE dept = ''Engineering'' ) AS engineers\nWHERE\n...\n`\n\nA non-recursive CTE is basically a query-local VIEW. There are several advantages and caveats to them. The syntax is more readable than a nested FROM (SELECT ...).\\\nA CTE can refer to another and it can be referenced from multiple places.\n\nA CTE referencing Another CTE\n\nUsing this format makes for a more readable SQL than a nested FROM(SELECT ...) clause:\n\n`sql\nWITH engineers AS (\nSELECT  FROM employees\nWHERE dept IN(''Development'',''Support'') ),\neu_engineers AS ( SELECT  FROM engineers WHERE country IN(''NL'',...) )\nSELECT\n...\nFROM eu_engineers;\n`\n\nMultiple Uses of a CTE\n\nThis can be an ''anti-self join'', for example:\n\n`sql\nWITH engineers AS (\nSELECT  FROM employees\nWHERE dept IN(''Development'',''Support'') )\n\nSELECT  FROM engineers E1\nWHERE NOT EXISTS\n   (SELECT 1 FROM engineers E2\n    WHERE E2.country=E1.country\n    AND E2.name <> E1.name );\n`\n\nOr, for year-over-year comparisons, for example:\n\n`sql\nWITH sales_product_year AS (\nSELECT product, YEAR(ship_date) AS year,\nSUM(price) AS total_amt\nFROM item_sales\nGROUP BY product, year )\n\nSELECT \nFROM sales_product_year CUR,\nsales_product_year PREV,\nWHERE CUR.product=PREV.product \nAND  CUR.year=PREV.year + 1 \nAND CUR.total_amt > PREV.total_amt\n`\n\nAnother use is to compare individuals against their group. Below is an example of how this might be executed:\n\n`sql\nWITH sales_product_year AS (\nSELECT product,\nYEAR(ship_date) AS year,\nSUM(price) AS total_amt\nFROM item_sales\nGROUP BY product, year\n)\n\nSELECT  \nFROM sales_product_year S1\nWHERE\ntotal_amt > \n    (SELECT 0.1 * SUM(total_amt)\n     FROM sales_product_year S2\n     WHERE S2.year = S1.year)\n``\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/common-table-expressions/non-recursive-common-table-expressions-overview', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/common-table-expressions/non-recursive-common-table-expressions-overview');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (664, 27, 'Recursive Common Table Expressions Overview', 'Description\n-----------\n\nCommon Table Expressions (CTEs) are a standard SQL feature, and are essentially temporary named result sets. They are defined using the WITH clause and can be referenced like tables within the main query. CTEs first appeared in the SQL standard in 1999, and the first implementations began appearing in 2007.\n\nMariaDB supports two types of CTEs:\n\n Non-recursive;\n Recursive, which this article covers.\n\nRecursive CTE\n\nA recursive CTE will repeatedly execute subsets of the data until it obtains the complete result set. This makes it particularly useful for handling hierarchical or tree-structured data, such as organizational charts, category trees, or parent-child relationships. max_recursive_iterations avoids infinite loops. CTEs permit a query to reference itself. SQL is generally poor at recursive structures.\n\n!trees_and_graphs\n\nRecursive CTE Syntax\n\nWITH RECURSIVE signifies a recursive CTE. It is given a name, followed by a body (the main query). The body consists of two parts:\n\n An anchor member (the initial query)\n A recursive member (which references the CTE itself).\n\n!rcte_syntax\n\nComputation\n\nGiven the following structure:\n\n!rcte_computation\n\n1. First execute the anchor part of the query:\n\n!rcte1\n\n2. Next, execute the recursive part of the query:\n\n!rcte_computation_2\n\n![](../../../../../.gitbook/assets/rcte_computation_2b.png)\n\n![](../../../../../.gitbook/assets/rcte_computation_3.png)\n\n![](../../../../../.gitbook/assets/rcte_computation_3b.png)\n\n![](../../../../../.gitbook/assets/rcte_computation_4.png)\n\nSummary\n\n``sql\nWITH RECURSIVE R AS (\n  SELECT anchor_data\n  UNION [all]\n  SELECT recursive_part\n  FROM R, ...\n)\nSELECT ...\n`\n\n1. Compute anchor_data.\n2. Compute recursive_part to get the new data.\n3. If (new data is non-empty) go to 2.\n\nRecursive CTE Examples\n\nTransitive closure - determining bus destinations\n\nSample data:\n\n!tc_1\n\n`sql\nCREATE TABLE bus_routes (origin VARCHAR(50), dst VARCHAR(50));\nINSERT INTO bus_routes VALUES \n  (''New York'', ''Boston''), \n  (''Boston'', ''New York''), \n  (''New York'', ''Washington''), \n  (''Washington'', ''Boston''), \n  (''Washington'', ''Raleigh'');\n`\n\nNow, we want to return the bus destinations with New York as the origin:\n\n`sql\nWITH RECURSIVE bus_dst as ( \n    SELECT origin as dst FROM bus_routes WHERE origin=''New York'' \n  UNION\n    SELECT bus_routes.dst FROM bus_routes JOIN bus_dst ON bus_dst.dst= bus_routes.origin \n) \nSELECT  FROM bus_dst;\n+------------+\n| dst        |\n+------------+\n| New York   |\n| Boston     |\n| Washington |\n| Raleigh    |\n+------------+\n`\n\nThe above example is computed as follows:\n\nFirst, the anchor data is calculated:\n\n Starting from New York.\n Boston and Washington are added.\n\nNext, the recursive part:\n\n Starting from Boston and then Washington.\n Raleigh is added.\n UNION excludes nodes that are already present.\n\nComputing paths - determining bus routes\n\nThis time, we are trying to get bus routes such as “New York -> Washington -> Raleigh”.\n\nUsing the same sample data as the previous example:\n\n`sql\nWITH RECURSIVE paths (cur_path, cur_dest) AS (\n    SELECT origin, origin FROM bus_routes WHERE origin=''New York'' \n  UNION\n    SELECT CONCAT(paths.cur_path, '','', bus_routes.dst), bus_routes.dst \n     FROM paths\n     JOIN bus_routes \n       ON paths.cur_dest = bus_routes.origin AND \n         NOT FIND_IN_SET(bus_routes.dst, paths.cur_path)\n) \nSELECT * FROM paths;\n+-----------------------------+------------+\n| cur_path                    | cur_dest   |\n+-----------------------------+------------+\n| New York                    | New York   |\n| New York,Boston             | Boston     |\n| New York,Washington         | Washington |\n| New York,Washington,Boston  | Boston     |\n| New York,Washington,Raleigh | Raleigh    |\n+-----------------------------+------------+\n``\n\nType Resolution and Data Truncation\n\nIn previous versions of MariaDB, the data type of a Recursive CTE column was entirely determined by the Anchor (non-recursive) part. If the Recursive part carried out calculations that generated a greater value, the data was silently truncated, leading to incorrect results.\n\nStarting with the versions listed below, MariaDB prevents silent data loss. The server now validates that the data generated by the recursive part matches the column types given by the anchor part. If a mismatch that leads to truncation is detected, the query will now fail with an error. See MDEV-12325 for more information.\n\n<table><thead><tr><th width="296">MariaDB Series </th><th>Fixed Version</th></tr></thead><tbody><tr><td>10.3</td><td>10.3.36 </td></tr><tr><td>10.4</td><td>10.4.26</td></tr><tr><td>10.5 </td><td>10.5.17</td></tr><tr><td>10.6</td><td>10.6.9</td></tr><tr><td>10.7</td><td>10.7.5</td></tr></tbody></table>\n\nExamples\n--------\n\nCREATE TABLE t1\n(\n  id INT,     -- employee ID\n  mid INT,    -- manager ID, or NULL if top level employee\n  name TEXT   -- employee name\n);\nINSERT INTO t1 VALUES (0,NULL, ''Name'');\nINSERT INTO t1 VALUES (1,0,    ''Name1'');\nINSERT INTO t1 VALUES (2,0,    ''Name2'');\nINSERT INTO t1 VALUES (11,1,   ''Name11'');\nINSERT INTO t1 VALUES (12,1,   ''Name12'');\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/common-table-expressions/recursive-common-table-expressions-overview', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/common-table-expressions/recursive-common-table-expressions-overview');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (665, 27, 'WITH', 'Syntax\n------\n\nWITH [RECURSIVE] table_reference [(columns_list)] AS  (\n  SELECT ...\n)\n[CYCLE cycle_column_list RESTRICT]\nSELECT ...\n\nDescription\n-----------\n\nThe WITH keyword signifies a Common Table Expression (CTE). It allows you to refer to a subquery expression many times in a query, as if having a temporary table that only exists for the duration of a query.\n\nThere are two kinds of CTEs:\n\n Non-Recursive.\n Recursive (signified by the RECURSIVE keyword).\n\nYou can use table_reference as any normal table in the external SELECT part. You can also use WITH in subqueries, as well as with EXPLAIN and SELECT.\n\nPoorly-formed recursive CTEs can in theory cause infinite loops. The max_recursive_iterations system variable limits the number of recursions.\n\nCYCLE ... RESTRICT\n\nThe CYCLE clause enables CTE cycle detection, avoiding excessive or infinite loops,\\\nMariaDB supports a relaxed, non-standard grammar.\\\nThe SQL Standard permits a CYCLE clause, as follows:\n\n``sql\nWITH RECURSIVE ... (\n  ...\n)\nCYCLE <cycle column list>\nSET <cycle mark column> TO <cycle mark value> DEFAULT <non-cycle mark value>\nUSING <path column>\n`\n\nwhere all clauses are mandatory.\\\nMariaDB does not support this, but permits a non-standard relaxed grammar, as follows:\n\n`sql\nWITH RECURSIVE ... (\n  ...\n)\nCYCLE <cycle column list> RESTRICT\n`\n\nWith the use of CYCLE ... RESTRICT it makes no difference whether the CTE uses UNION ALL or UNION DISTINCT anymore. UNION ALL means "all rows, but without cycles", which is exactly what the CYCLE clause enables. And UNION DISTINCT means all rows should be different, which, again, is what will happen — as uniqueness is enforced over a subset of columns, complete rows will automatically all be different.\n\nCYCLE ... RESTRICT` is not available.\n\nExamples\n--------\n\nWITH t AS (SELECT a FROM t1 WHERE b >= ''c'') \n  SELECT * FROM t2, t WHERE t2.c = t.a;\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/common-table-expressions/with', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/common-table-expressions/with');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (666, 27, 'DUAL', 'Description\n-----------\n\nYou can use DUAL instead of a table name in situations where no tables are referenced, such as the following SELECT statement:\n\n``sql\nSELECT 1 + 1 FROM DUAL;\n+-------+\n| 1 + 1 |\n+-------+\n|     2 |\n+-------+\n`\n\nDUAL is purely for the convenience of people who require that all SELECT statements should haveFROM and possibly other clauses. MariaDB ignores the clauses. MariaDB does not require FROM DUAL if no tables are referenced.\n\nFROM DUAL could be used when you only SELECT computed values, but require a WHERE clause, perhaps to test that a script correctly handles empty resultsets:\n\n`sql\nSELECT 1 FROM DUAL WHERE FALSE;\nEmpty set (0.00 sec)\n``\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/dual', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/dual');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (667, 27, 'FOR UPDATE', 'Description\n-----------\n\nInnoDB supports row-level locking. Selected rows can be locked using LOCK IN SHARE MODE or FOR UPDATE. In both cases, a lock is acquired on the rows read by the query, and it will be released when the current transaction is committed.\n\nThe FOR UPDATE clause of SELECT applies only when autocommit is set to 0 or the SELECT is enclosed in a transaction. A lock is acquired on the rows, and other transactions are prevented from writing the rows, acquire locks, and from reading them (unless their isolation level is READ UNCOMMITTED).\n\nIf autocommit is set to 1, the LOCK IN SHARE MODE and FOR UPDATE clauses have no effect in InnoDB. For non-transactional storage engines like MyISAM and ARIA, a table level lock will be taken even if autocommit is set to 1.\n\nIf the isolation level is set to SERIALIZABLE, all plain SELECT statements are converted to SELECT ... LOCK IN SHARE MODE.\n\nExamples\n--------\n\nSELECT * FROM trans WHERE period=2001 FOR UPDATE;\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/for-update', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/for-update');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (668, 27, 'GROUP BY', 'Description\n-----------\n\nUse the GROUP BY clause in a SELECT statement to group rows together that have the same value in one or more column, or the same computed value using expressions with any functions and operators except grouping functions. When you use a GROUP BY clause, you will get a single result row for each group of rows that have the same value for the expression given in GROUP BY.\n\nWhen grouping rows, grouping values are compared as if by the = operator. For string values, the = operator ignores trailing whitespace and may normalize characters and ignore case, depending on the collation in use.\n\nYou can use any of the grouping functions in your select expression. Their values will be calculated based on all the rows that have been grouped together for each result row. If you select a non-grouped column or a value computed from a non-grouped column, it is undefined which row the returned value is taken from. This is not permitted if the ONLY_FULL_GROUP_BY SQL_MODE is used.\n\nYou can use multiple expressions in the GROUP BY clause, separated by commas.\\\nRows are grouped together if they match on each of the expressions.\n\nYou can also use a single integer as the grouping expression. If you use an integer _n_,\\\nthe results will be grouped by the _n_th column in the select expression.\n\nThe WHERE clause is applied before the GROUP BY clause. It filters non-aggregated\\\nrows before the rows are grouped together. To filter grouped rows based on aggregate values, use the HAVING clause. The HAVING clause takes any expression and evaluates it as a boolean, just like the WHERE clause. You can use grouping functions in the HAVING clause. As with the select expression, if you reference non-grouped columns in the HAVING clause, the behavior is undefined.\n\nBy default, if a GROUP BY clause is present, the rows in the output will be sorted by the expressions used in the GROUP BY. You can also specify ASC or DESC (ascending, descending) after those expressions, like in ORDER BY. The default is ASC.\n\nIf you want the rows to be sorted by another field, you can add an explicit ORDER BY. If you don''t want the result to be ordered, you can add ORDER BY NULL.\n\nWITH ROLLUP\n\nThe WITH ROLLUP modifier adds extra rows to the result set that represent super-aggregate summaries. For a full description with examples, see SELECT WITH ROLLUP.\n\nGROUP BY Examples\n\nConsider the following table that records how many times each user has played and won a game:\n\n``sql\nCREATE TABLE plays (name VARCHAR(16), plays INT, wins INT);\nINSERT INTO plays VALUES \n  ("John", 20, 5), \n  ("Robert", 22, 8), \n  ("Wanda", 32, 8), \n  ("Susan", 17, 3);\n`\n\nGet a list of win counts along with a count:\n\n`sql\nSELECT wins, COUNT() FROM plays GROUP BY wins;\n+------+----------+\n| wins | COUNT() |\n+------+----------+\n|    3 |        1 |\n|    5 |        1 |\n|    8 |        2 |\n+------+----------+\n3 rows in set (0.00 sec)\n`\n\nThe GROUP BY expression can be a computed value, and can refer back to an identifier specified with AS. Get a list of win averages along with a count:\n\n`sql\nSELECT (wins / plays) AS winavg, COUNT() FROM plays GROUP BY winavg;\n+--------+----------+\n| winavg | COUNT() |\n+--------+----------+\n| 0.1765 |        1 |\n| 0.2500 |        2 |\n| 0.3636 |        1 |\n+--------+----------+\n3 rows in set (0.00 sec)\n`\n\nYou can use any grouping function in the select expression. For each win average as above, get a list of the average play count taken to get that average:\n\n`sql\nSELECT (wins / plays) AS winavg, AVG(plays) FROM plays \n  GROUP BY winavg;\n+--------+------------+\n| winavg | AVG(plays) |\n+--------+------------+\n| 0.1765 |    17.0000 |\n| 0.2500 |    26.0000 |\n| 0.3636 |    22.0000 |\n+--------+------------+\n3 rows in set (0.00 sec)\n`\n\nYou can filter on aggregate information using the HAVING clause. The HAVING clause is applied after GROUP BY and allows you to filter on aggregate data that is not available to the WHERE clause. Restrict the above example to results that involve an average number of plays over 20:\n\n`sql\nSELECT (wins / plays) AS winavg, AVG(plays) FROM plays \n  GROUP BY winavg HAVING AVG(plays) > 20;\n+--------+------------+\n| winavg | AVG(plays) |\n+--------+------------+\n| 0.2500 |    26.0000 |\n| 0.3636 |    22.0000 |\n+--------+------------+\n2 rows in set (0.00 sec)\n``\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/group-by', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/group-by');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (669, 27, 'Advanced Joins', 'Description\n-----------\n\nThis article is a continuation of the Joining Tables with JOIN Clauses Guide. If you''re getting started with JOIN statements, review that page first.\n\nThe Employee Database\n\nLet us begin by using an example employee database of a fairly small family business, which does not anticipate expanding in the future.\n\nFirst, we create the table that will hold all of the employees and their contact information:\n\n``sql\nCREATE TABLE Employees (\n  ID TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT,\n  First_Name VARCHAR(25) NOT NULL,\n  Last_Name VARCHAR(25) NOT NULL,\n  Position VARCHAR(25) NOT NULL,\n  Home_Address VARCHAR(50) NOT NULL,\n  Home_Phone VARCHAR(12) NOT NULL,\n  PRIMARY KEY (ID)\n) ENGINE=MyISAM;\n`\n\nNext, we add a few employees to the table:\n\n`sql\nINSERT INTO Employees (First_Name, Last_Name, Position, Home_Address, Home_Phone)\n  VALUES\n  (''Mustapha'', ''Mond'', ''Chief Executive Officer'', ''692 Promiscuous Plaza'', ''326-555-3492''),\n  (''Henry'', ''Foster'', ''Store Manager'', ''314 Savage Circle'', ''326-555-3847''),\n  (''Bernard'', ''Marx'', ''Cashier'', ''1240 Ambient Avenue'', ''326-555-8456''),\n  (''Lenina'', ''Crowne'', ''Cashier'', ''281 Bumblepuppy Boulevard'', ''328-555-2349''),\n  (''Fanny'', ''Crowne'', ''Restocker'', ''1023 Bokanovsky Lane'', ''326-555-6329''),\n  (''Helmholtz'', ''Watson'', ''Janitor'', ''944 Soma Court'', ''329-555-2478'');\n`\n\nNow, we create a second table, containing the hours which each employee clocked in and out during the week:\n\n`sql\nCREATE TABLE Hours (\n  ID TINYINT(3) UNSIGNED NOT NULL,\n  Clock_In DATETIME NOT NULL,\n  Clock_Out DATETIME NOT NULL\n) ENGINE=MyISAM;\n`\n\nFinally, although it is a lot of information, we add a full week of hours for each of the employees into the second table that we created:\n\n`sql\nINSERT INTO Hours\n  VALUES\n  (''1'', ''2005-08-08 07:00:42'', ''2005-08-08 17:01:36''),\n  (''1'', ''2005-08-09 07:01:34'', ''2005-08-09 17:10:11''),\n  (''1'', ''2005-08-10 06:59:56'', ''2005-08-10 17:09:29''),\n  (''1'', ''2005-08-11 07:00:17'', ''2005-08-11 17:00:47''),\n  (''1'', ''2005-08-12 07:02:29'', ''2005-08-12 16:59:12''),\n  (''2'', ''2005-08-08 07:00:25'', ''2005-08-08 17:03:13''),\n  (''2'', ''2005-08-09 07:00:57'', ''2005-08-09 17:05:09''),\n  (''2'', ''2005-08-10 06:58:43'', ''2005-08-10 16:58:24''),\n  (''2'', ''2005-08-11 07:01:58'', ''2005-08-11 17:00:45''),\n  (''2'', ''2005-08-12 07:02:12'', ''2005-08-12 16:58:57''),\n  (''3'', ''2005-08-08 07:00:12'', ''2005-08-08 17:01:32''),\n  (''3'', ''2005-08-09 07:01:10'', ''2005-08-09 17:00:26''),\n  (''3'', ''2005-08-10 06:59:53'', ''2005-08-10 17:02:53''),\n  (''3'', ''2005-08-11 07:01:15'', ''2005-08-11 17:04:23''),\n  (''3'', ''2005-08-12 07:00:51'', ''2005-08-12 16:57:52''),\n  (''4'', ''2005-08-08 06:54:37'', ''2005-08-08 17:01:23''),\n  (''4'', ''2005-08-09 06:58:23'', ''2005-08-09 17:00:54''),\n  (''4'', ''2005-08-10 06:59:14'', ''2005-08-10 17:00:12''),\n  (''4'', ''2005-08-11 07:00:49'', ''2005-08-11 17:00:34''),\n  (''4'', ''2005-08-12 07:01:09'', ''2005-08-12 16:58:29''),\n  (''5'', ''2005-08-08 07:00:04'', ''2005-08-08 17:01:43''),\n  (''5'', ''2005-08-09 07:02:12'', ''2005-08-09 17:02:13''),\n  (''5'', ''2005-08-10 06:59:39'', ''2005-08-10 17:03:37''),\n  (''5'', ''2005-08-11 07:01:26'', ''2005-08-11 17:00:03''),\n  (''5'', ''2005-08-12 07:02:15'', ''2005-08-12 16:59:02''),\n  (''6'', ''2005-08-08 07:00:12'', ''2005-08-08 17:01:02''),\n  (''6'', ''2005-08-09 07:03:44'', ''2005-08-09 17:00:00''),\n  (''6'', ''2005-08-10 06:54:19'', ''2005-08-10 17:03:31''),\n  (''6'', ''2005-08-11 07:00:05'', ''2005-08-11 17:02:57''),\n  (''6'', ''2005-08-12 07:02:07'', ''2005-08-12 16:58:23'');\n`\n\nWorking with the Employee Database\n\nNow that we have a cleanly structured database to work with, let us begin this tutorial by stepping up one notch from the last tutorial and filtering our information a little.\n\nFiltering by Name\n\nEarlier in the week, an anonymous employee reported that Helmholtz came into work almost four minutes late; to verify this, we will begin our investigation by filtering out employees whose first names are "Helmholtz":\n\n`sql\nSELECT\n  Employees.First_Name,\n  Employees.Last_Name,\n  Hours.Clock_In,\n  Hours.Clock_Out\nFROM Employees\nINNER JOIN Hours ON Employees.ID = Hours.ID\nWHERE Employees.First_Name = ''Helmholtz'';\n`\n\nThe result looks like this:\n\n`\n+------------+-----------+---------------------+---------------------+\n| First_Name | Last_Name | Clock_In            | Clock_Out           |\n+------------+-----------+---------------------+---------------------+\n| Helmholtz  | Watson    | 2005-08-08 07:00:12 | 2005-08-08 17:01:02 |\n| Helmholtz  | Watson    | 2005-08-09 07:03:44 | 2005-08-09 17:00:00 |\n| Helmholtz  | Watson    | 2005-08-10 06:54:19 | 2005-08-10 17:03:31 |\n| Helmholtz  | Watson    | 2005-08-11 07:00:05 | 2005-08-11 17:02:57 |\n| Helmholtz  | Watson    | 2005-08-12 07:02:07 | 2005-08-12 16:58:23 |\n+------------+-----------+---------------------+---------------------+\n5 rows in set (0.00 sec)\n`\n\nThis is obviously more information than we care to trudge through, considering we only care about when he arrived past 7:00:59 on any given day within this week; thus, we need to add a couple more conditions to our WHERE clause.\n\nFiltering by Name, Date and Time\n\nIn the following example, we will filter out all of the times which Helmholtz clocked in that were before 7:01:00 and during the work week that lasted from the 8th to the 12th of August:\n\n`sql\nSELECT\n  Employees.First_Name,\n  Employees.Last_Name,\n  Hours.Clock_In,\n  Hours.Clock_Out\nFROM Employees\nINNER JOIN Hours ON Employees.ID = Hours.ID\nWHERE Employees.First_Name = ''Helmholtz''\nAND DATE_FORMAT(Hours.Clock_In, ''%Y-%m-%d'') >= ''2005-08-08''\nAND DATE_FORMAT(Hours.Clock_In, ''%Y-%m-%d'') <= ''2005-08-12''\nAND DATE_FORMAT(Hours.Clock_In, ''%H:%i:%S'') > ''07:00:59'';\n`\n\nThe result looks like this:\n\n`\n+------------+-----------+---------------------+---------------------+\n| First_Name | Last_Name | Clock_In            | Clock_Out           |\n+------------+-----------+---------------------+---------------------+\n| Helmholtz  | Watson    | 2005-08-09 07:03:44 | 2005-08-09 17:00:00 |\n| Helmholtz  | Watson    | 2005-08-12 07:02:07 | 2005-08-12 16:58:23 |\n+------------+-----------+---------------------+---------------------+\n2 rows in set (0.00 sec)\n`\n\nBy merely adding a few more conditions, we eliminated all of the irrelevant information; Helmholtz was late to work on the 9th and the 12th of August.\n\nDisplaying Total Work Hours per Day\n\nSuppose you would like to—based on the information stored in both of our tables in the employee database—develop a quick list of the total hours each employee has worked for each day recorded; a simple way to estimate the time each employee worked per day is exemplified below:\n\n`sql\nSELECT\n  Employees.ID,\n  Employees.First_Name,\n  Employees.Last_Name,\n  Hours.Clock_In,\n  Hours.Clock_Out,\nDATE_FORMAT(Hours.Clock_Out, ''%T'')-DATE_FORMAT(Hours.Clock_In, ''%T'') \nAS ''Total_Hours''\nFROM Employees \nINNER JOIN Hours ON Employees.ID = Hours.ID;\n`\n\nThe result (limited to 10 rows) looks like this:\n\n`\n+----+------------+-----------+---------------------+---------------------+-------------+\n| ID | First_Name | Last_Name | Clock_In            | Clock_Out           | Total_Hours |\n+----+------------+-----------+---------------------+---------------------+-------------+\n|  1 | Mustapha   | Mond      | 2005-08-08 07:00:42 | 2005-08-08 17:01:36 |          10 |\n|  1 | Mustapha   | Mond      | 2005-08-09 07:01:34 | 2005-08-09 17:10:11 |          10 |\n|  1 | Mustapha   | Mond      | 2005-08-10 06:59:56 | 2005-08-10 17:09:29 |          11 |\n|  1 | Mustapha   | Mond      | 2005-08-11 07:00:17 | 2005-08-11 17:00:47 |          10 |\n|  1 | Mustapha   | Mond      | 2005-08-12 07:02:29 | 2005-08-12 16:59:12 |           9 |\n|  2 | Henry      | Foster    | 2005-08-08 07:00:25 | 2005-08-08 17:03:13 |          10 |\n|  2 | Henry      | Foster    | 2005-08-09 07:00:57 | 2005-08-09 17:05:09 |          10 |\n|  2 | Henry      | Foster    | 2005-08-10 06:58:43 | 2005-08-10 16:58:24 |          10 |\n|  2 | Henry      | Foster    | 2005-08-11 07:01:58 | 2005-08-11 17:00:45 |          10 |\n|  2 | Henry      | Foster    | 2005-08-12 07:02:12 | 2005-08-12 16:58:57 |           9 |\n+----+------------+-----------+---------------------+---------------------+-------------+\n10 rows in set (0.00 sec)\n``\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/joins-subqueries/joins/more-advanced-joins', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/joins-subqueries/joins/more-advanced-joins');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (670, 27, 'Subqueries', 'Description\n-----------\n\nsubqueries-and-all.md\n\nCompare a value against all results from a subquery. The ALL operator returns TRUE if the comparison holds for every row returned by the subquery.\n\nsubqueries-and-any.md\n\nCompare a value against any result from a subquery. The ANY (or SOME) operator returns TRUE if the comparison holds for at least one row. IN can be used for =ANY.\n\nsubqueries-and-exists.md\n\nTest for the existence of rows. The EXISTS operator returns TRUE if the subquery returns at least one row, often used for correlated subqueries.\n\nsubqueries-and-joins.md\n\nUnderstand when to use subqueries versus joins. This guide explains performance implications and how to rewrite subqueries as joins for efficiency.\n\nsubqueries-in-a-from-clause-derived-tables.md\n\nUse a subquery as a temporary table. Derived tables allow you to select from the result set of another query within the FROM clause.\n\nsubqueries-row-subqueries.md\n\nRetrieve a single row of multiple values. A row subquery returns a tuple that can be compared against a row constructor in the outer query.\n\nsubqueries-scalar-subqueries.md\n\nReturn a single value. A scalar subquery produces a one-row, one-column result that can be used anywhere a constant or expression is valid.\n\nsubquery-limitations.md\n\nReview restrictions on subquery usage. This page details unsupported operations, such as modifying a table while selecting from it in a subquery.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/joins-subqueries/subqueries/README', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/joins-subqueries/subqueries/README');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (671, 27, 'Subqueries and ALL', 'Description\n-----------\n\nSubqueries using the ALL keyword will return true if the comparison returns true for each row returned by the subquery, or the subquery returns no rows.\n\nSyntax\n\n``sql\nscalar_expression comparison_operator ALL <Table subquery>\n`\n\n scalar_expression may be any expression that evaluates to a single value.\n comparison_operator may be any one of: =, >, <, >=, <=, <> or !=\n\nALL returns:\n\n NULL if the comparison operator returns NULL for at least one row returned by the Table subquery or scalar_expression returns NULL.\n FALSE if the comparison operator returns FALSE for at least one row returned by the Table subquery.\n TRUE if the comparison operator returns TRUE for all rows returned by the Table subquery, or if Table subquery returns no rows.\n\nNOT IN is an alias for <> ALL`.\n\nExamples\n--------\n\nCREATE TABLE sq1 (num TINYINT);\n\nCREATE TABLE sq2 (num2 TINYINT);\n\nINSERT INTO sq1 VALUES(100);\n\nINSERT INTO sq2 VALUES(40),(50),(60);\n\nSELECT  FROM sq1 WHERE num > ALL (SELECT * FROM sq2);\n+------+\n| num  |\n+------+\n|  100 |\n+------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/joins-subqueries/subqueries/subqueries-and-all', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/joins-subqueries/subqueries/subqueries-and-all');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (672, 27, 'Subqueries With ANY and SOME', 'Description\n-----------\n\nSyntax\n\nSOME is a synonym for ANY.&#x20;\n\n``sql\nscalar_expression comparison_operator ANY <Table subquery>\nscalar_expression comparison_operator SOME <Table subquery>\n`\n\n scalar_expression may be any expression that evaluates to a single value.\n comparison_operator may be any one of =, >, <, >=, <=, <> or !=.\n\nAbout IN\n\nAlthough IN functions similarly to = ANY, it is documented separately due to unique optimization characteristics. Refer to Subqueries with IN and NOT IN for more details.\n\nANY or SOME returns:\n\n TRUE if the comparison operator returns TRUE for at least one row returned by the table subquery.\n FALSE if the comparison operator returns FALSE for all rows returned by the table subquery, or if the table subquery has no rows.\n* NULL if the comparison operator returns NULL for at least one row returned by the table subquery and doesn''t returns TRUE for any of them, or if scalar_expression returns NULL`.\n\nExamples\n--------\n\nCREATE TABLE sq1 (num1 TINYINT);\nCREATE TABLE sq2 (num2 TINYINT);\nINSERT INTO sq1 VALUES(100);\nINSERT INTO sq2 VALUES(40),(50),(120);\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/joins-subqueries/subqueries/subqueries-and-any', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/joins-subqueries/subqueries/subqueries-and-any');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (673, 27, 'Subqueries and EXISTS', 'Syntax\n------\n\nSELECT ... WHERE EXISTS <Table subquery>\n\nDescription\n-----------\n\nSubqueries using the EXISTS keyword will return true if the subquery returns any rows. Conversely, subqueries using NOT EXISTS will return true only if the subquery returns no rows from the table.\n\nEXISTS subqueries ignore the columns specified by the SELECT of the subquery, since they''re not relevant. For example,\n\n``sql\nSELECT col1 FROM t1 WHERE EXISTS (SELECT  FROM t2);\n`\n\nand\n\n`sql\nSELECT col1 FROM t1 WHERE EXISTS (SELECT col2 FROM t2);\n``\n\nproduce identical results.\n\nExamples\n--------\n\nCREATE TABLE sq1 (num TINYINT);\n\nCREATE TABLE sq2 (num2 TINYINT);\n\nINSERT INTO sq1 VALUES(100);\n\nINSERT INTO sq2 VALUES(40),(50),(60);\n\nSELECT  FROM sq1 WHERE EXISTS (SELECT  FROM sq2 WHERE num2>50);\n+------+\n| num  |\n+------+\n|  100 |\n+------+\n\nSELECT  FROM sq1 WHERE NOT EXISTS (SELECT * FROM sq2 GROUP BY num2 HAVING MIN(num2)=40);\nEmpty set (0.00 sec)\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/joins-subqueries/subqueries/subqueries-and-exists', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/joins-subqueries/subqueries/subqueries-and-exists');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (674, 27, 'Subqueries and JOINs', 'Description\n-----------\n\nA subquery can quite often, but not in all cases, be rewritten as a JOIN.\n\nRewriting Subqueries as JOINS\n\nA subquery using IN can be rewritten with the DISTINCT keyword. Consider this query:\n\n``sql\nSELECT  FROM table1 WHERE col1 IN (SELECT col1 FROM table2);\n`\n\nIt can be rewritten like this:\n\n`sql\nSELECT DISTINCT table1. FROM table1, table2 WHERE table1.col1=table2.col1;\n`\n\nNOT IN or NOT EXISTS queries can also be rewritten. For example, these two queries return the same result:\n\n`sql\nSELECT  FROM table1 WHERE col1 NOT IN (SELECT col1 FROM table2);\nSELECT  FROM table1 WHERE NOT EXISTS (SELECT col1 FROM table2 \n         WHERE table1.col1=table2.col1);\n`\n\nThey can both be rewritten like this:\n\n`sql\nSELECT table1. FROM table1 LEFT JOIN table2 ON table1.id=table2.id \n       WHERE table2.id IS NULL;\n`\n\nSubqueries that can be rewritten as a LEFT JOIN are sometimes more efficient.\n\nUsing Subqueries instead of JOINS\n\nThere are some scenarios, though, which call for subqueries rather than joins:\n\n When you want duplicates, but not false duplicates. Suppose Table_1 has three rows — {1,1,2}\\\n  — and Table_2 has two rows\\\n  — {1,2,2}. If you need to list the rows\\\n  in Table_1 which are also in Table_2, only this subquery-based SELECT statement will give the right answer (1,1,2):\n\n`sql\nSELECT Table_1.column_1 \nFROM   Table_1 \nWHERE  Table_1.column_1 IN \n  (SELECT Table_2.column_1 \n    FROM   Table_2);\n`\n\n This SQL statement won''t work:\n\n`sql\nSELECT Table_1.column_1 \nFROM   Table_1,Table_2 \nWHERE  Table_1.column_1 = Table_2.column_1;\n`\n\n because the result will be {1,1,2,2}\\\n  — and the duplication of 2 is an error. This SQL statement won''t work either:\n\n`sql\nSELECT DISTINCT Table_1.column_1 \nFROM   Table_1,Table_2 \nWHERE  Table_1.column_1 = Table_2.column_1;\n`\n\n because the result will be {1,2} — and the removal of the duplicated 1 is an error too.\n When the outermost statement is not a query. The SQL statement:\n\n`sql\nUPDATE Table_1 SET column_1 = (SELECT column_1 FROM Table_2);\n`\n\n can''t be expressed using a join unless some rare SQL3 features are used.\n When the join is over an expression. The SQL statement:\n\n`sql\nSELECT  FROM Table_1 \nWHERE column_1 + 5 =\n  (SELECT MAX(column_1) FROM Table_2);\n`\n\n is hard to express with a join. In fact, the only way we can think of is this SQL statement:\n\n`sql\nSELECT Table_1.\nFROM   Table_1, \n      (SELECT MAX(column_1) AS max_column_1 FROM Table_2) AS Table_2\nWHERE  Table_1.column_1 + 5 = Table_2.max_column_1;\n`\n\n which still involves a parenthesized query, so nothing is gained from the transformation.\n When you want to see the exception. For example, suppose the question is: Which books are longer than Das Kapital? These two queries are effectively almost the same:\n\n`sql\nSELECT DISTINCT Bookcolumn_1.                     \nFROM   Books AS Bookcolumn_1 JOIN Books AS Bookcolumn_2 USING(page_count) \nWHERE  title = ''Das Kapital'';\n\nSELECT DISTINCT Bookcolumn_1. \nFROM   Books AS Bookcolumn_1 \nWHERE  Bookcolumn_1.page_count > \n  (SELECT DISTINCT page_count \n  FROM   Books AS Bookcolumn_2 \n  WHERE  title = ''Das Kapital'');\n`\n\n The difference is between these two SQL statements is, if there are two editions of Das Kapital (with different page counts), then the self-join example will return the books which are longer than the shortest edition of Das Kapital. That might be the wrong answer, since the original question didn''t ask for "... longer than ANY` book named Das Kapital" (it seems to contain a false assumption that there''s only one edition).\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/joins-subqueries/subqueries/subqueries-and-joins', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/joins-subqueries/subqueries/subqueries-and-joins');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (675, 27, 'Subqueries in a FROM Clause (Derived Tables)', 'Description\n-----------\n\nAlthough subqueries are more commonly placed in a WHERE clause, they can also form part of the FROM clause. Such subqueries are commonly called derived tables.\n\nIf a subquery is used in this way, you must also use an AS clause to name the result of the subquery.\n\nORACLE mode\n\nMariaDB starting with 10.6.0\n\nAnonymous subqueries in a FROM clause (no AS clause) are permitted in ORACLE mode.\n\nAnonymous subqueries in a FROM clause (no AS clause) are not permitted in ORACLE mode.\n\nCorrelation Column List\n\nMariaDB starting with 11.7.0\n\nIt is possible to assign column names in the derived table name syntax element.\n\nIt is not possible to assign column names in the derived table name syntax element.\n\nExamples\n--------\n\nCREATE TABLE student (name CHAR(10), test CHAR(10), score TINYINT); \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-statements/data-manipulation/selecting-data/joins-subqueries/subqueries/subqueries-in-a-from-clause-derived-tables', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/joins-subqueries/subqueries/subqueries-in-a-from-clause-derived-tables');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (676, 27, 'Row Subqueries', 'Description\n-----------\n\nA row subquery is a subquery returning a single row, as opposed to a scalar subquery, which returns a single column from a row, or a literal.\n\nExamples\n--------\n\nCREATE TABLE staff (name VARCHAR(10), age TINYINT);\n\nCREATE TABLE customer (name VARCHAR(10), age TINYINT);\n\nINSERT INTO staff VALUES (''Bilhah'',37), (''Valerius'',61), (''Maia'',25);\n\nINSERT INTO customer VALUES (''Thanasis'',48), (''Valerius'',61), (''Brion'',51);\n\nSELECT * FROM staff WHERE (name,age) = (SELECT name,age FROM customer WHERE name=''Valerius'');\n+----------+------+\n| name     | age  |\n+----------+------+\n| Valerius |   61 |\n+----------+------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/joins-subqueries/subqueries/subqueries-row-subqueries', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/joins-subqueries/subqueries/subqueries-row-subqueries');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (677, 27, 'Scalar Subqueries', 'Description\n-----------\n\nA scalar subquery is a subquery that returns a single value. This is the simplest form of a subquery, and can be used in most places a literal or single column value is valid.\n\nThe data type, length and character set and collation are all taken from the result returned by the subquery. The result of a subquery can always be NULL, that is, no result returned. Even if the original value is defined as NOT NULL, this is disregarded.\n\nA subquery cannot be used where only a literal is expected, for example LOAD DATA INFILE expects a literal string containing the file name, and LIMIT requires a literal integer.\n\nExamples\n--------\n\nCREATE TABLE sq1 (num TINYINT);\n\nCREATE TABLE sq2 (num TINYINT);\n\nINSERT INTO sq1 VALUES (1);\n\nINSERT INTO sq2 VALUES (10 (SELECT num FROM sq1));\n\nSELECT  FROM sq2;\n+------+\n| num  |\n+------+\n|   10 |\n+------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/joins-subqueries/subqueries/subqueries-scalar-subqueries', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/joins-subqueries/subqueries/subqueries-scalar-subqueries');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (678, 27, 'Subquery Limitations', 'Description\n-----------\n\nThere are a number of limitations regarding subqueries, which are discussed below.\n\nThe following tables and data will be used in the examples that follow:\n\n``sql\nCREATE TABLE staff(name VARCHAR(10),age TINYINT);\n\nCREATE TABLE customer(name VARCHAR(10),age TINYINT);\n`\n\n`sql\nINSERT INTO staff VALUES \n(''Bilhah'',37), (''Valerius'',61), (''Maia'',25);\n\nINSERT INTO customer VALUES \n(''Thanasis'',48), (''Valerius'',61), (''Brion'',51);\n`\n\nORDER BY and LIMIT\n\nTo use ORDER BY or limit LIMIT in subqueries both must be used.. For example:\n\n`sql\nSELECT  FROM staff WHERE name IN (SELECT name FROM customer ORDER BY name);\n+----------+------+\n| name     | age  |\n+----------+------+\n| Valerius |   61 |\n+----------+------+\n`\n\nis valid, but\n\n`sql\nSELECT  FROM staff WHERE name IN (SELECT NAME FROM customer ORDER BY name LIMIT 1);\nERROR 1235 (42000): This version of MariaDB doesn''t \n  yet support ''LIMIT & IN/ALL/ANY/SOME subquery''\n`\n\nis not.\n\nModifying and Selecting from the Same Table\n\nIt''s not possible to both modify and select from the same table in a subquery. For example:\n\n`sql\nDELETE FROM staff WHERE name = (SELECT name FROM staff WHERE age=61);\nERROR 1093 (HY000): Table ''staff'' is specified twice, both \n  as a target for ''DELETE'' and as a separate source for data\n`\n\nRow Comparison Operations\n\nThere is only partial support for row comparison operations. The expression in\n\n`sql\nexpr op {ALL|ANY|SOME} subquery,\n`\n\nmust be scalar and the subquery can only return a single column.\n\nHowever, because of the way IN is implemented (it is rewritten as a sequence of = comparisons and AND), the expression in\n\n`sql\nexpression [NOT] IN subquery\n`\n\nis permitted to be an n-tuple and the subquery can return rows of n-tuples.\n\nFor example:\n\n`sql\nSELECT  FROM staff WHERE (name,age) NOT IN (\n  SELECT name,age FROM customer WHERE age >=51]\n);\n+--------+------+\n| name   | age  |\n+--------+------+\n| Bilhah |   37 |\n| Maia   |   25 |\n+--------+------+\n`\n\nis permitted, but\n\n`sql\nSELECT  FROM staff WHERE (name,age) = ALL (\n  SELECT name,age FROM customer WHERE age >=51\n);\nERROR 1241 (21000): Operand should contain 1 column(s)\n`\n\nis not.\n\nCorrelated Subqueries\n\nSubqueries in the FROM clause cannot be correlated subqueries. They cannot be evaluated for each row of the outer query since they are evaluated to produce a result set during when the query is executed.\n\nStored Functions\n\nA subquery can refer to a stored function which modifies data. This is an extension to the SQL standard, but can result in indeterminate outcomes. For example, take:\n\n`sql\nSELECT ... WHERE x IN (SELECT f() ...);\n``\n\nwhere _f()_ inserts rows. The function _f()_ could be executed a different number of times depending on how the optimizer chooses to handle the query.\n\nThis sort of construct is therefore not safe to use in replication that is not row-based, as there could be different results on the master and the slave.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/joins-subqueries/subqueries/subquery-limitations', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/joins-subqueries/subqueries/subquery-limitations');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (679, 27, 'Joins', 'Description\n-----------\n\njoin-syntax.md\n\nMain JOIN page, documenting all join types available in MariaDB.\n\nmariadb-join-guide.md\n\nIntroduction to joining tables in MariaDB.\n\nmore-advanced-joins.md\n\nIntroduction to advanced joins in MariaDB.\n\ncomma-vs-join.md\n\nHow to use a comma instead of a JOIN clause, and why you should always prefer the latter.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/joins/README', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/joins/README');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (680, 27, 'Comma vs JOIN', 'Description\n-----------\n\nA query to retrieve the list of phone numbers for clients who ordered in the last two weeks might be written in a couple of ways. Here are two:\n\n``sql\nSELECT \nFROM\n  clients,\n  orders,\n  phoneNumbers\nWHERE\n  clients.id = orders.clientId\n  AND clients.id = phoneNumbers.clientId\n  AND orderPlaced >= NOW() - INTERVAL 2 WEEK;\n`\n\n`sql\nSELECT \nFROM\n  clients\n  INNER JOIN orders ON clients.id = orders.clientId\n  INNER JOIN phoneNumbers ON clients.id = phoneNumbers.clientId\nWHERE\n  orderPlaced >= NOW() - INTERVAL 2 WEEK;\n`\n\nDoes it make a difference? Not much as written. But you should use the second form, for these reasons:\n\n Readability. Once the WHERE clause contains more than two conditions, it becomes tedious to pick out the difference between business logic (only dates in the last two weeks) and relational logic (which fields relate clients to orders). Using the JOIN syntax with an ON clause makes the WHERE list shorter, and makes it very easy to see how tables relate to each other.\n Flexibility. Let''s say we need to see all clients even if they don''t have a phone number in the system. With the second version, it''s easy; just change INNER JOIN phoneNumbers to LEFT JOIN phoneNumbers. Try that with the first version, and recent MySQL versions will issue a syntax error because of the change in precedence between the comma operator and the JOIN keyword. The solution is to rearrange the FROM` clause or add parentheses to override the precedence, and that quickly becomes frustrating.\n* Portability. If your queries use standard SQL syntax, you will have an easier time switching to a different database should the need ever arise.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/joins/comma-vs-join', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/joins/comma-vs-join');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (681, 27, 'JOIN Syntax', 'Description\n-----------\n\nMariaDB supports the following JOIN syntaxes for the table_references part of SELECT statements and multiple-table DELETE and UPDATE statements:\n\n``sql\ntable_references:\n    table_reference [, table_reference] ...\n\ntable_reference:\n    table_factor\n  | join_table\n\ntable_factor (<= MariaDB 11.6):\n    tbl_name [PARTITION (partition_list)]\n        [query_system_time_period_specification] [[AS] alias] [index_hint_list]\n  | table_subquery [query_system_time_period_specification] [AS] alias\n  | ( table_references )\n  | { ON table_reference LEFT OUTER JOIN table_reference\n        ON conditional_expr }\n\ntable_factor (>= MariaDB 11.7):\n    tbl_name [PARTITION (partition_list)]\n        [query_system_time_period_specification] [[AS] alias] [index_hint_list]\n  | table_subquery [query_system_time_period_specification] [AS] alias [(column_name_list)] \n  | ( table_references )\n  | { ON table_reference LEFT OUTER JOIN table_reference\n        ON conditional_expr }\n\njoin_table:\n    table_reference [INNER | CROSS] JOIN table_factor [join_condition]\n  | table_reference STRAIGHT_JOIN table_factor\n  | table_reference STRAIGHT_JOIN table_factor ON conditional_expr\n  | table_reference {LEFT|RIGHT} [OUTER] JOIN table_reference join_condition\n  | table_reference NATURAL [{LEFT|RIGHT} [OUTER]] JOIN table_factor\n\njoin_condition:\n    ON conditional_expr\n  | USING (column_list)\n\nquery_system_time_period_specification:\n    FOR SYSTEM_TIME AS OF point_in_time\n  | FOR SYSTEM_TIME BETWEEN point_in_time AND point_in_time\n  | FOR SYSTEM_TIME FROM point_in_time TO point_in_time\n  | FOR SYSTEM_TIME ALL\n\npoint_in_time:\n    [TIMESTAMP] expression\n  | TRANSACTION expression\n\nindex_hint_list:\n    index_hint [, index_hint] ...\n\nindex_hint:\n    USE {INDEX|KEY}\n      [{FOR {JOIN|ORDER BY|GROUP BY}] ([index_list])\n  | IGNORE {INDEX|KEY}\n      [{FOR {JOIN|ORDER BY|GROUP BY}] (index_list)\n  | FORCE {INDEX|KEY}\n      [{FOR {JOIN|ORDER BY|GROUP BY}] (index_list)\n\nindex_list:\n    index_name [, index_name] ...\n`\n\nA _table reference_ is also known as a _join expression_.\n\nEach table can also be specified as db_name.tabl_name. This allows to write queries which involve multiple databases. See Identifier Qualifiers for syntax details.\n\nThe syntax of table_factor is an extension to the SQL Standard. The latter accepts only table_reference, not a list of them inside a pair of parentheses.\n\nThis is a conservative extension if we consider each comma in a list of table_reference items as equivalent to an inner join. Consider this query:\n\n`sql\nSELECT  FROM t1 LEFT JOIN (t2, t3, t4)\n                 ON (t2.a=t1.a AND t3.b=t1.b AND t4.c=t1.c)\n`\n\nIt is equivalent to this query:\n\n`sql\nSELECT  FROM t1 LEFT JOIN (t2 CROSS JOIN t3 CROSS JOIN t4)\n                 ON (t2.a=t1.a AND t3.b=t1.b AND t4.c=t1.c)\n`\n\nIn MariaDB, CROSS JOIN is a syntactic equivalent toINNER JOIN (they can replace each other). In standard SQL, they are not equivalent. INNER JOIN is used with anON clause, CROSS JOIN is used otherwise.\n\nIn general, parentheses can be ignored in join expressions containing only inner join operations. MariaDB also supports nested joins (see Nested Join Optimization).\n\nSubqueries\n\nA table subquery is specified as a parenthesized query and must contain a following derived table name (specified as _alias_ in the above syntax specification).\n\nYou can optionally specify a list of column names in parenthesis.\n\n`sql\nSELECT ic1, ic2, ic3 FROM\n      (\n        SELECT c1, c2, c3 FROM t1 GROUP BY c1\n      ) dt2 (ic1, ic2, ic3)\n    JOIN t2 ON t2.c1 = dt2.ic1\n    WHERE c2 > 0\n    GROUP BY ic1\n`\n\nHere, the table subquery for t1 will be materialized and named dt2, with column names ic1, ic2, ic3. These column names are used outside the subquery.\n\nYou cannot optionally specify a list of column names in parenthesis.\n\nSee also Correlation Column List.\n\nSystem-Versioned Tabled\n\nSee System-versioned tables for more information about the FOR SYSTEM_TIME syntax.\n\nIndex Hints\n\nIndex hints can be specified to affect how the MariaDB optimizer makes use of indexes. For more information, see How to force query plans.\n\nOracle Mode\n\nThis feature is available from MariaDB 12.1.\n\nOverview\n\nWhen Oracle mode is active, the Oracle-style (+)  syntax can be used. For example, the following two queries are identical:\n\n`sql\nSELECT  FROM t1 LEFT JOIN t2 ON t1.a = t2.b;\n`\n\n`sql\nSELECT  FROM t1, t2 WHERE t1.a = t2.b(+);\n`\n\nSimilarly, the following two queries are identical:\n\n`sql\nSELECT  FROM t1 RIGHT JOIN t2 ON t1.a = t2.b;\n`\n\n`sql\nSELECT  FROM t1, t2 WHERE t1.a(+) = t2.b;\n`\n\nWith more than two tables, these two queries are identical:\n\n`sql\nSELECT  FROM t1 LEFT JOIN t2 ON t1.a = t2.a LEFT JOIN t3 ON t2.a = t3.a\n`\n\n`sql\nSELECT  FROM t1, t2, t3 WHERE t1.a = t2.a(+) AND t2.a = t3.a(+)\n`\n\nTo "rewrite" a join query using the (+) syntax, use EXPLAIN EXTENDED (the last line is an approximation at using the "regular" LEFT JOIN syntax):\n\n`sql\nEXPLAIN EXTENDED\n    SELECT  FROM t1, t2, t3 WHERE t1.a = t2.a(+) AND t2.a = t3.a(+);\nid	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra\n1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	100.00	\n1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where; Using join buffer (flat, BNL join)\n1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where; Using join buffer (incremental, BNL join)\nWarnings:\nNote	1003	select "test"."t1"."a" AS "a","test"."t2"."a" AS "a","test"."t3"."a" AS "a" from "test"."t1" left join "test"."t2" on("test"."t2"."a" = "test"."t1"."a") left join "test"."t3" on("test"."t3"."a" = "test"."t2"."a") where 1\n`\n\nLimitations\n\nThe table whose columns are marked with the (+) operator in a subexpression (a part of the WHERE clause divided by AND) are the inner part of the expression. A table whose columns are not marked with the operator belong to the outer part.\n\nExample of a single subexpression within a WHERE clause:\n\n`sql\n... WHERE t1.a = t2.a(+)\n`\n\nExample of two subexpressions within a WHERE clause – here, both t1.a = t2.a(+)  and t2.a = t3.a(+) are inner parts, because both contain a (+) operator:\n\n`sql\n... WHERE t1.a = t2.a(+) AND t2.a = t3.a(+)\n`\n\nExample of two subexpressions within a WHERE clause – here, t1.a = t2.a(+) is the inner part (because of the (+) operator), and t2.a = 42 is the outer part (it doesn''t have a (+) operator:\n\n`sql\n... WHERE t1.a = t2.a(+) AND t2.a = 42\n`\n\n"Rewritten" as a "regular" join, that clause looks like this:\n\n`sql\n... FROM t1 LEFT JOIN t2 ON (t1.a = t2.a) WHERE t2.a = 42\n`\n\nThe following limitations apply:\n\n The (+) operator can only be used in a WHERE clause.\n The (+) operator can only be applied to a table column, and the column should be from the local SELECT, not from an outer SELECT.\n The (+) operator cannot be used with other JOIN methods – it must be a comma-separated list in the FROM clause.\n When the WHERE clause is split into subexpressions by AND, (+) cannot be used.\n The (+) operator cannot be used on the right side of an IN function.\n The (+) operator cannot be used in row operations.\n The (+) operator cannot be used when two or more tables are on one side of and marked with the (+) operator and some are not.\n The (+) operator cannot create loops (or cycles) of dependence, where the same table appears on both sides of the operator in one expression, or through a chain of expressions.\n\nError Codes\n\nThe following errors may occur when not adhering to the (+) operator limitations or for other reasons:\n\n ER_INVALID_USE_OF_ORA_JOIN\n ER_INVALID_USE_OF_ORA_JOIN_OUTER_REF\n ER_INVALID_USE_OF_ORA_JOIN_WRONG_FUNC\n ER_INVALID_USE_OF_ORA_JOIN_ONE_TABLE\n ER_INVALID_USE_OF_ORA_JOIN_CYCLE\n\nYou can find examples of the errors by error code in these files (which are available on GitHub):\n\n mysql-test/suite/compat/oracle/t/ora_outer_join.test\n mysql-test/suite/compat/oracle/t/ora_outer_join_err.test`\n\nExamples\n--------\n\nSELECT left_tbl.*\n  FROM left_tbl LEFT JOIN right_tbl ON left_tbl.id = right_tbl.id\n  WHERE right_tbl.id IS NULL;\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/joins/join-syntax', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/joins/join-syntax');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (682, 27, 'LIMIT', 'Description\n-----------\n\nUse the LIMIT clause to restrict the number of returned rows. When you use a single integer _n_ with LIMIT, the first _n_ rows will be returned. Use the ORDER BY clause to control which rows come first. You can also select a number of rows after an offset using either of the following:\n\n``sql\nLIMIT offset, row_count\nLIMIT row_count OFFSET offset\n`\n\nWhen you provide an offset _m_ with a limit _n_, the first _m_ rows will be ignored, and the following _n_ rows will be returned.\n\nExecuting an UPDATE with the LIMIT clause is not safe for replication. LIMIT 0 is an exception to this rule (see MDEV-6170).\n\nThere is a LIMIT ROWS EXAMINED optimization which provides the means to terminate the execution of SELECT statements which examine too many rows, and thus use too many resources. See LIMIT ROWS EXAMINED.\n\nMulti-Table Updates\n\nIt is possible to use LIMIT (or ORDER BY) in a multi-table UPDATE statement.\n\nIt is not possible to use LIMIT (or ORDER BY) in a multi-table UPDATE statement.\n\nGROUP_CONCAT\n\nIt is possible to use LIMIT with GROUP_CONCAT().\n\nIt is not possible to use LIMIT` with GROUP_CONCAT().\n\nExamples\n--------\n\nCREATE TABLE members (name VARCHAR(20));\nINSERT INTO members VALUES(''Jagdish''),(''Kenny''),(''Rokurou''),(''Immaculada'');\n\nSELECT * FROM members;\n+------------+\n| name       |\n+------------+\n| Jagdish    |\n| Kenny      |\n| Rokurou    |\n| Immaculada |\n+------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/limit', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/limit');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (683, 27, 'LOCK IN SHARE MODE', 'Description\n-----------\n\nInnoDB supports row-level locking. Selected rows can be locked using LOCK IN SHARE MODE or FOR UPDATE. In both cases, a lock is acquired on the rows read by the query, and it will be released when the current transaction is committed.\n\nWhen LOCK IN SHARE MODE is specified in a SELECT statement, MariaDB will wait until all transactions that have modified the rows are committed. Then, a read lock is acquired. All transactions can read the rows, but if they want to modify them, they have to wait until your transaction is committed.\n\nInnoDB locks index records rather than logical rows. If a SELECT is satisfied by a secondary index (a covering index read), it just locks that index. Instead, the primary key records will be locked if a concurrent UPDATE modifies columns outside of that index. These locks do not overlap under READ COMMITTED isolation level, so the update can proceed. To ensure a block is used, the SELECT query must reference columns from the primary index.\n\nFor further information and an example, see InnoDB Lock Modes.\n\nIf autocommit is set to 1 (the default), the LOCK IN SHARE MODE and FOR UPDATE clauses have no effect in InnoDB. For non-transactional storage engines like MyISAM and ARIA, a table level lock will be taken even if autocommit is set to 1.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/lock-in-share-mode', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/lock-in-share-mode');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (684, 27, 'ORDER BY', 'Description\n-----------\n\nUse the ORDER BY clause to order a resultset, such as that are returned from a SELECT statement. You can specify just a column or use any expression with functions. If you are using the GROUP BY clause, you can use grouping functions in ORDER BY. Ordering is done after grouping.\n\nYou can use multiple ordering expressions, separated by commas. Rows are sorted by the first expression, then by the second expression if they have the same value for the first, and so on.\n\nYou can use the keywords ASC and DESC after each ordering expression to force that ordering to be ascending or descending, respectively. Ordering is ascending by default.\n\nYou can also use a single integer as the ordering expression. If you use an integer _n_, the results is ordered by the n<sup>th</sup> column in the select expression.\n\nWhen string values are compared, they are compared as if by the STRCMP function. STRCMP ignores trailing whitespace and may normalize characters and ignore case, depending on the collation in use.\n\nDuplicated entries in the ORDER BY clause are removed.\n\nORDER BY can also be used to order the activities of a DELETE or UPDATE statement (usually with the LIMIT clause).\n\nIt is possible to use ORDER BY (or LIMIT) in a multi-table UPDATE statement.\n\nIt is not possible to use ORDER BY (or LIMIT) in a multi-table UPDATE statement.\n\nMariaDB allows packed sort keys and values of non-sorted fields in the sort buffer. This can make filesort temporary files much smaller when VARCHAR, CHAR or BLOB columns are used, notably speeding up some ORDER BY sorts.\n\nMariaDB does not allow packed sort keys and values of non-sorted fields in the sort buffer.\n\nExamples\n--------\n\nCREATE TABLE seq (i INT, x VARCHAR(1));\nINSERT INTO seq VALUES (1,''a''), (2,''b''), (3,''b''), (4,''f''), (5,''e'');\n\nSELECT  FROM seq ORDER BY i;\n+------+------+\n| i    | x    |\n+------+------+\n|    1 | a    |\n|    2 | b    |\n|    3 | b    |\n|    4 | f    |\n|    5 | e    |\n+------+------+\n\nSELECT  FROM seq ORDER BY i DESC;\n+------+------+\n| i    | x    |\n+------+------+\n|    5 | e    |\n|    4 | f    |\n|    3 | b    |\n|    2 | b    |\n|    1 | a    |\n+------+------+\n\nSELECT * FROM seq ORDER BY x,i;\n+------+------+\n| i    | x    |\n+------+------+\n|    1 | a    |\n|    2 | b    |\n|    3 | b    |\n|    5 | e    |\n|    4 | f    |\n+------+------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/order-by', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/order-by');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (685, 27, 'PROCEDURE', 'Description\n-----------\n\nThe PROCEDURE clause of SELECT passes the whole result set to a Procedure which will process it. These Procedures are not Stored Procedures, and can only be written in the C language, so it is necessary to recompile the server.\n\nCurrently, the only available procedure is ANALYSE, which examines the resultset and suggests the optimal datatypes for each column. It is defined in the sql/sql_analyse.cc file, and can be used as an example to create more Procedures.\n\nThis clause cannot be used in a view definition.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/procedure', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/procedure');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (686, 27, 'SELECT INTO DUMPFILE', 'Syntax\n------\n\nSELECT ... INTO DUMPFILE ''file_path''\n\nDescription\n-----------\n\nSELECT ... INTO DUMPFILE is a SELECT clause which writes the resultset into a single unformatted row, without any separators, in a file. The results will not be returned to the client.\n\n_file_path_ can be an absolute path, or a relative path starting from the data directory. It can only be specified as a string literal, not as a variable. However, the statement can be dynamically composed and executed as a prepared statement to work around this limitation.\n\nThis statement is binary-safe and so is particularly useful for writing BLOB values to file. It can be used, for example, to copy an image or an audio document from the database to a file.\n\nThe file must not exist. It cannot be overwritten. A user needs the FILE privilege to run this statement. Also, MariaDB needs permission to write files in the specified location. If the secure_file_priv system variable is set to a non-empty directory name, the file can only be written to that directory.\n\nThe character_set_filesystem system variable has controlled interpretation of file names that are given as literal strings.\n\nThe character_set_filesystem system variable does not have controlled interpretation of file names that are given as literal strings.\n\nExamples\n--------\n\nSELECT _utf8''Hello world!'' INTO DUMPFILE ''/tmp/world'';\n\nSELECT LOAD_FILE(''/tmp/world'') AS world;\n+--------------+\n| world        |\n+--------------+\n| Hello world! |\n+--------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/select-into-dumpfile', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/select-into-dumpfile');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (687, 27, 'SELECT INTO OUTFILE', 'Syntax\n------\n\nSELECT ... INTO OUTFILE ''file_name''\n        [CHARACTER SET charset_name]\n        [export_options]\n\nexport_options:\n    [{FIELDS | COLUMNS}\n        [TERMINATED BY ''string'']\n        [[OPTIONALLY] ENCLOSED BY ''char'']\n        [ESCAPED BY ''char'']\n    ]\n    [LINES\n        [STARTING BY ''string'']\n        [TERMINATED BY ''string'']\n    ]\n\nDescription\n-----------\n\nSELECT INTO OUTFILE writes the resulting rows to a file, and allows the use of column and row terminators to specify a particular output format. The default is to terminate fields with tabs () and lines with newlines ().\n\nThe file must not exist. It cannot be overwritten. A user needs the FILE privilege to run this statement. Also, MariaDB needs permission to write files in the specified location. If the secure_file_priv system variable is set to a non-empty directory name, the file can only be written to that directory.\n\nThe LOAD DATA INFILE statement complements SELECT INTO OUTFILE.\n\nCharacter Sets\n\nThe CHARACTER SET clause specifies the character set in which the results are to be written. Without the clause, no conversion takes place (the binary character set). In this case, if there are multiple character sets, the output will contain these too, and may not easily be able to be reloaded.\n\nIn cases where you have two servers using different character-sets, using SELECT INTO OUTFILE to transfer data from one to the other can have unexpected results. To ensure that MariaDB correctly interprets the escape sequences, use the CHARACTER SET clause on both the SELECT INTO OUTFILE statement and the subsequent LOAD DATA INFILE statement.\n\nExamples\n--------\n\nSELECT customer_id, firstname, surname FROM customer\n  INTO OUTFILE ''/exportdata/customers.txt''\n  FIELDS TERMINATED BY '','' OPTIONALLY ENCLOSED BY ''"''\n  LINES TERMINATED BY ''\\n'';\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/select-into-outfile', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/select-into-outfile');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (688, 27, 'SELECT ... OFFSET ... FETCH', 'Syntax\n------\n\nOFFSET start { ROW | ROWS }\nFETCH { FIRST | NEXT } [ count ] { ROW | ROWS } { ONLY | WITH TIES }\n\nDescription\n-----------\n\nThe OFFSET clause allows one to return only those elements of a resultset that come after a specified offset. The FETCH clause specifies the number of rows to return, while ONLY or WITH TIES specifies whether or not to also return any further results that tie for last place according to the ordered resultset.\n\nEither the singular ROW or the plural ROWS can be used after the OFFSET and FETCH clauses; the choice has no impact on the results.\n\nFIRST and NEXT give the same result.\n\nIn the case of WITH TIES, an ORDER BY clause is required, otherwise an error will be returned.\n\n``sql\nSELECT i FROM t1 FETCH FIRST 2 ROWS WITH TIES;\nERROR 4180 (HY000): FETCH ... WITH TIES requires ORDER BY clause to be present\n``\n\nExamples\n--------\n\nCREATE OR REPLACE TABLE t1 (i INT);\nINSERT INTO t1 VALUES (1),(2),(3),(4), (4), (5);\nSELECT i FROM t1 ORDER BY i ASC;\n+------+\n| i    |\n+------+\n|    1 |\n|    2 |\n|    3 |\n|    4 |\n|    4 |\n|    5 |\n+------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/select-offset-fetch', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/select-offset-fetch');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (689, 27, 'SELECT WITH ROLLUP', 'Description\n-----------\n\nThe WITH ROLLUP modifier adds extra rows to the result set that represent super-aggregate summaries. The super-aggregated column is represented by a NULL value. Multiple aggregates over different columns will be added if there are multiple GROUP BY columns.\n\nThe LIMIT clause can be used at the same time, and is applied after the WITH ROLLUP rows have been added.\n\nWITH ROLLUP cannot be used with ORDER BY. Some sorting is still possible by using ASC or DESC clauses with the GROUP BY column, although the super-aggregate rows will always be added last.\n\nExamples\n--------\n\nCREATE TABLE booksales ( \n  country VARCHAR(35), genre ENUM(''fiction'',''non-fiction''), year YEAR, sales INT);\n\nINSERT INTO booksales VALUES\n  (''Senegal'',''fiction'',2014,12234), (''Senegal'',''fiction'',2015,15647),\n  (''Senegal'',''non-fiction'',2014,64980), (''Senegal'',''non-fiction'',2015,78901),\n  (''Paraguay'',''fiction'',2014,87970), (''Paraguay'',''fiction'',2015,76940),\n  (''Paraguay'',''non-fiction'',2014,8760), (''Paraguay'',''non-fiction'',2015,9030);\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/select-with-rollup', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/select-with-rollup');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (690, 27, 'SELECT', 'Syntax\n------\n\nSELECT\n    [/+ hints /]\n    [/+ JOIN_PREFIX(argument_list) /]\n    [/+ JOIN_ORDER(argument_list) /]\n    [/+ JOIN_FIXED_ORDER(argument_list) /]\n    [/+ JOIN_SUFFIX(argument_list) /]\n    [/+ MAX_EXECUTION_TIME(milliseconds) /]\n    [ALL | DISTINCT | DISTINCTROW]\n    [HIGH_PRIORITY]\n    [STRAIGHT_JOIN]\n    [SQL_SMALL_RESULT] [SQL_BIG_RESULT] [SQL_BUFFER_RESULT]\n    [SQL_CACHE | SQL_NO_CACHE] [SQL_CALC_FOUND_ROWS]\n    select_expr [, select_expr ...]\n    [ FROM table_references\n      [WHERE where_condition]\n      [GROUP BY {col_name | expr | position} [ASC | DESC], ... [WITH ROLLUP]]\n      [HAVING where_condition]\n      [ORDER BY {col_name | expr | position} [ASC | DESC], ...]\n      [LIMIT {[offset,] row_count | row_count OFFSET offset  \n      [ROWS EXAMINED rows_limit] } |\n        [OFFSET start { ROW | ROWS }]\n        [FETCH { FIRST | NEXT } [ count ] { ROW | ROWS } { ONLY | WITH TIES }] ]\n      procedure|[PROCEDURE procedure_name(argument_list)]\n      [INTO OUTFILE ''file_name'' [CHARACTER SET charset_name] [export_options] |\n        INTO DUMPFILE ''file_name'' | INTO var_name [, var_name] ]\n      [FOR UPDATE lock_option | LOCK IN SHARE MODE lock_option]\nexport_options:\n    [{FIELDS | COLUMNS}\n        [TERMINATED BY ''string'']\n        [[OPTIONALLY] ENCLOSED BY ''char'']\n        [ESCAPED BY ''char'']\n    ]\n    [LINES\n        [STARTING BY ''string'']\n        [TERMINATED BY ''string'']\n    ]\nlock_option:\n    [WAIT n | NOWAIT | SKIP LOCKED]\n\nDescription\n-----------\n\nSELECT is used to retrieve rows selected from one or more tables, and can include UNION statements and subqueries.\n\n Each select_expr expression indicates a column or data that you want to retrieve. You must have at least one select expression. See Select Expressions below.\n The FROM clause indicates the table or tables from which to retrieve rows. Use either a single table name or a JOIN expression. See JOIN for details. If no table is involved, FROM DUAL can be specified.\n Each table can also be specified as db_name.tabl_name. Each column can also be specified as tbl_name.col_name or even db_name.tbl_name.col_name. This allows one to write queries which involve multiple databases. See Identifier Qualifiers for syntax details.\n The WHERE clause, if given, indicates the condition or conditions that rows must satisfy to be selected. The where_condition is an expression that evaluates to true for each row to be selected. The statement selects all rows if there is no WHERE clause.\n   In the WHERE clause, you can use any of the functions and operators that MariaDB supports, except for aggregate (summary) functions. See Functions and Operators and Functions and Modifiers for use with GROUP BY (aggregate).\n Use the ORDER BY clause to order the results.\n Use the LIMIT clause to restrict the results to only a certain number of rows, optionally with an offset.\n Use the GROUP BY and HAVING clauses to group rows together when they have columns or computed values in common.\n\nSELECT can also be used to retrieve rows computed without reference to any table.\n\nSelect Expressions\n\nA SELECT statement must contain one or more select expressions, separated by commas. Each select expression can be one of the following:\n\n The name of a column.\n Any expression using functions and operators.\n  to select all columns from all tables in the FROM clause.\n tbl_name. to select all columns from just the table tbl_name.\n\nWhen specifying a column, you can either use just the column name or qualify the column name with the name of the table using tbl_name.col_name. The qualified form is useful if you are joining multiple tables in the FROM clause. If you do not qualify the column names when selecting from multiple tables, MariaDB will try to find the column in each table. It is an error if that column name exists in multiple tables.\n\nYou can quote column names using backticks. If you are qualifying column names with table names, quote each part separately as `tbl_name.col_name.\n\nIf you use any grouping functions in any of the select expressions, all rows in your results will be implicitly grouped, as if you had used GROUP BY NULL. GROUP BY NULL being an expression behaves specially such that the entire result set is treated as a group.\n\nDISTINCT\n\nA query may produce some identical rows. By default, all rows are retrieved, even when their values are the same. To explicitly specify that you want to retrieve identical rows, use the ALL option. If you want duplicates to be removed from the result set, use the DISTINCT option. DISTINCTROW is a synonym for DISTINCT. See also COUNT DISTINCT and SELECT UNIQUE in Oracle mode.\n\nINTO\n\nThe INTO clause is used to specify that the query results should be written to a file or variable.\n\n SELECT INTO OUTFILE - formatting and writing the result to an external file.\n SELECT INTO DUMPFILE - binary-safe writing of the unformatted results to an external file.\n* SELECT INTO Variable - selecting and setting variables.\n\nThe reverse of SELECT INTO OUTFILE is LOAD DATA.\n\nLIMIT\n\nRestricts the number of returned rows. See LIMIT and LIMIT ROWS EXAMINED for details.\n\nLOCK IN SHARE MODE/FOR UPDATE\n\nSee LOCK IN SHARE MODE and FOR UPDATE for details on the respective locking clauses.\n\nOFFSET ... FETCH\n\nSee SELECT ... OFFSET ... FETCH.\n\nThe clause doesn''t exist.\n\nORDER BY\n\nOrder a result set. See ORDER BY for details.\n\nPARTITION\n\nSpecifies to the optimizer which partitions are relevant for the query. Other partitions will not be read. See Partition Pruning and Selection for details.\n\nPROCEDURE\n\nPasses the whole result set to a C Procedure. See PROCEDURE and PROCEDURE ANALYSE (the only built-in procedure not requiring the server to be recompiled).\n\nSKIP LOCKED\n\nThis causes rows that couldn''t be locked (LOCK IN SHARE MODE or FOR UPDATE) to be excluded from the result set. An explicit NOWAIT is implied here. This is only implemented on InnoDB tables and ignored otherwise.\n\nThe clause doesn''t exist.\n\nOptimizer Hints\n\nThese include HIGH_PRIORITY, STRAIGHT_JOIN, SQL_SMALL_RESULT | SQL_BIG_RESULT, SQL_BUFFER_RESULT, SQL_CACHE | SQL_NO_CACHE, and SQL_CALC_FOUND_ROWS.\n\nSee Optimizer Hints for details.\n\nmax_statement_time clause\n\nBy using max_statement_time in conjunction with SET STATEMENT, it is possible to limit the execution time of individual queries. For example:\n\n`sql\nSET STATEMENT max_statement_time=100 FOR \n  SELECT field1 FROM table_name ORDER BY field1;\n``\n\nWAIT/NOWAIT\n\nSet the lock wait timeout. See WAIT and NOWAIT.\n\nExamples\n--------\n\nSELECT f1,f2 FROM t1 WHERE (f3<=10) AND (f4=''y'');\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/select', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/select');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (691, 27, 'EXCEPT', 'Syntax\n------\n\nSELECT ...\n(INTERSECT [ALL | DISTINCT] | EXCEPT [ALL | DISTINCT] | UNION [ALL | DISTINCT]) \n  SELECT ...\n[(INTERSECT [ALL | DISTINCT] | EXCEPT [ALL | DISTINCT] | UNION [ALL | DISTINCT]) \n  SELECT ...]\n[ORDER BY [{col_name | expr | position} [ASC | DESC] \n  [, {col_name | expr | position} [ASC | DESC] ...]]]\n[LIMIT {[offset,] row_count | row_count OFFSET offset}\n| OFFSET start { ROW | ROWS }\n| FETCH { FIRST | NEXT } [ count ] { ROW | ROWS } { ONLY | WITH TIES } ]\n\nDescription\n-----------\n\nMariaDB supports EXCEPT and INTERSECT in addition to UNION.\n\nThe queries before and after EXCEPT must be SELECT or VALUES statements.\n\nAll behavior for naming columns, ORDER BY and LIMIT is the same as for UNION. Note that the alternative SELECT ... OFFSET ... FETCH syntax is only supported. This allows us to use the WITH TIES clause.\n\nEXCEPT implicitly supposes a DISTINCT operation.\n\nThe result of EXCEPT is all records of the left SELECT result except records which are in right SELECT result set, i.e. it is subtraction of two result sets.\n\nEXCEPT and UNION have the same operation precedence and INTERSECT has a higher precedence, unless running in Oracle mode, in which case all three have the same precedence.\n\nParentheses\n\nParentheses can be used to specify precedence. Before this, a syntax error would be returned.\n\nMariaDB starting with 10.5.0\n\nALL/DISTINCT\n\nEXCEPT ALL and EXCEPT DISTINCT . The ALL operator leaves duplicates intact, while the DISTINCT operator removes duplicates. DISTINCT is the default behavior if neither operator is supplied.\n\nOnly EXCEPT DISTINCT is available.\n\nExamples\n--------\n\n(SELECT e_name AS name, email FROM customers)\nEXCEPT\n(SELECT c_name AS name, email FROM employees);\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/set-operations/except', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/set-operations/except');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (692, 27, 'INTERSECT', 'Syntax\n------\n\nSELECT ...\n(INTERSECT [ALL | DISTINCT] | EXCEPT [ALL | DISTINCT] | UNION [ALL | DISTINCT]) SELECT ...\n[(INTERSECT [ALL | DISTINCT] | EXCEPT [ALL | DISTINCT] | UNION [ALL | DISTINCT]) SELECT ...]\n[ORDER BY [column [, column ...]]]\n[LIMIT {[offset,] row_count | row_count OFFSET offset}]\n\nDescription\n-----------\n\nMariaDB has supported INTERSECT (as well as EXCEPT) in addition to UNION since MariaDB 10.3.\n\nAll behavior for naming columns, ORDER BY and LIMIT is the same as for UNION.\n\nINTERSECT implicitly supposes a DISTINCT operation.\n\nThe result of an intersect is the intersection of right and left SELECT results, i.e. only records that are present in both result sets will be included in the result of the operation.\n\nINTERSECT has higher precedence than UNION and EXCEPT (unless running running in Oracle mode, in which case all three have the same precedence). If possible it will be executed linearly, but if not, it will be translated to a subquery in the FROM clause:\n\n``sql\n(SELECT a,b FROM t1)\nUNION\n(SELECT c,d FROM t2)\nINTERSECT\n(SELECT e,f FROM t3)\nUNION\n(SELECT 4,4);\n`\n\nwill be translated to:\n\n`sql\n(SELECT a,b FROM t1)\nUNION\nSELECT c,d FROM\n  ((SELECT c,d FROM t2)\n   INTERSECT\n   (SELECT e,f FROM t3)) dummy_subselect\nUNION\n(SELECT 4,4)\n`\n\nParentheses\n\nParentheses can be used to specify precedence.\n\nParentheses cannot be used to specify precedence.\n\nMariaDB starting with 10.5.0\n\nALL/DISTINCT\n\nINTERSECT ALL and INTERSECT DISTINCT . The ALL operator leaves duplicates intact, while the DISTINCT operator removes duplicates. DISTINCT is the default behavior if neither operator is supplied.\n\nDISTINCT` is the only behavior available.\n\nExamples\n--------\n\n(SELECT e_name AS name, email FROM employees)\nINTERSECT\n(SELECT c_name AS name, email FROM customers);\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/set-operations/intersect', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/set-operations/intersect');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (693, 27, 'MINUS', 'Description\n-----------\n\nMINUS is available starting from MariaDB 10.6.1.\n\nMINUS is a synonym for EXCEPT when SQL_MODE=ORACLE is set.\n\n``sql\nCREATE TABLE seqs (i INT);\nINSERT INTO seqs VALUES (1),(2),(2),(3),(3),(4),(5),(6);\n\nSET SQL_MODE=''ORACLE'';\n\nSELECT i FROM seqs WHERE i <= 3 MINUS SELECT i FROM seqs WHERE i>=3;\n+------+\n| i    |\n+------+\n|    1 |\n|    2 |\n+------+\n``\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/set-operations/minus', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/set-operations/minus');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (694, 27, 'Precedence Control in Table Operations', 'Syntax\n------\n\n(  expression )\n[ORDER BY [column[, column...]]]\n[LIMIT {[offset,] row_count | row_count OFFSET offset}]\n\nDescription\n-----------\n\nUsing parentheses in SQL allows to control the order of execution for SELECT statements and Table Value Constructor, including UNION, EXCEPT, and INTERSECT operations. MariaDB executes the parenthetical expression before the rest of the statement. You can then use ORDER BY and LIMIT clauses the further organize the result set.\n\nThe Optimizer may rearrange the exact order in which MariaDB executes different parts of the statement. When it calculates the result set, however, it returns values as though the parenthetical expression were executed first.\n\nExamples\n--------\n\nCREATE TABLE test.t1 (num INT);\n\nINSERT INTO test.t1 VALUES (1),(2),(3);\n\n(SELECT  FROM test.t1 \n UNION \n VALUES (10)) \nINTERSECT \nVALUES (1),(3),(10),(11);\n+------+\n| num  |\n+------+\n|    1 |\n|    3 |\n|   10 |\n+------+\n\n((SELECT  FROM test.t1 \n  UNION \n  VALUES (10)) \n INTERSECT \n VALUES (1),(3),(10),(11)) \nORDER BY 1 DESC;\n+------+\n| num  |\n+------+\n|   10 |\n|    3 |\n|    1 |\n+------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/set-operations/precedence-control-in-table-operations', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/set-operations/precedence-control-in-table-operations');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (695, 27, 'UNION', 'Description\n-----------\n\nUNION is used to combine the results from multiple SELECT statements into a single result set.\n\nThe column names from the first SELECT statement are used as the column names for the results returned. Selected columns listed in corresponding positions of each SELECT statement should have the same data type. (For example, the first column selected by the first statement should have the same type as the first column selected by the other statements.)\n\nIf they don''t, the type and length of the columns in the result take into account the values returned by all of the SELECTs, so there is no need for explicit casting. Note that currently this is not the case for recursive CTEs - see MDEV-12325.\n\nTable names can be specified as db_name.tbl_name. This permits writing UNIONs which involve multiple databases. See Identifier Qualifiers for syntax details.\n\nUNION queries cannot be used with aggregate functions.\n\nEXCEPT and UNION have the same operation precedence and INTERSECT has a higher precedence, unless running in Oracle mode, in which case all three have the same precedence.\n\nALL/DISTINCT\n\nThe ALL keyword causes duplicate rows to be preserved. The DISTINCT keyword (the default if the keyword is omitted) causes duplicate rows to be removed by the results.\n\nUNION ALL and UNION DISTINCT can both be present in a query. In this case, UNION DISTINCT will override any UNION ALL to its left.\n\nThe server can in most cases execute UNION ALL without creating a temporary table (see MDEV-334).\n\nORDER BY and LIMIT\n\nIndividual SELECT statements can contain their own ORDER BY and LIMIT clauses. In this case, the individual queries need to be wrapped between parentheses. However, this does not affect the order of the UNION, so they only are useful to limit the record read by one SELECT.\n\nThe UNION can have global ORDER BY and LIMIT clauses, which affect the whole result set. If the columns retrieved by individual SELECT statements have an alias (AS), the ORDER BY must use that alias, not the real column names.\n\nHIGH_PRIORITY\n\nSpecifying a query as HIGH_PRIORITY does not work inside a UNION. If applied to the first SELECT, it is ignored. Applying to a later SELECT results in a syntax error:\n\n``sql\nERROR 1234 (42000): Incorrect usage/placement of ''HIGH_PRIORITY''\n`\n\nSELECT ... INTO ...\n\nIndividual SELECT statements cannot be written INTO DUMPFILE or INTO OUTFILE. If the last SELECT statement specifies INTO DUMPFILE or INTO OUTFILE, the entire result of the UNION will be written. Placing the clause after any other SELECT` will result in a syntax error.\n\nIf the result is a single row, SELECT ... INTO @var_name can also be used.\n\nParentheses\n\nParentheses can be used to specify precedence.\n\nParentheses cannot be used to specify precedence.\n\nExamples\n--------\n\n(SELECT e_name AS name, email FROM employees)\nUNION\n(SELECT c_name AS name, email FROM customers);\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/set-operations/union', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/set-operations/union');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (696, 27, 'Subqueries with IN and NOT IN', 'Description\n-----------\n\nThe IN operator tests whether a value is a member of a set of values returned by a subquery. It is the most commonly used construct for equality-based subquery comparisons in MariaDB.\n\nWhile IN is logically related to the ANY and SOME operators, it has distinct semantics and receives specialized treatment from the query optimizer.\n\nSyntax\n\n``sql\nscalar_expression [NOT] IN (subquery)\n`\n\n scalar_expression: An expression that evaluates to a single value.\n subquery: A subquery that returns a single column.\n\nRelationship to ANY and SOME\n\nIn MariaDB, IN is a synonym for = ANY.\n\n IN evaluates to TRUE if the comparison returns TRUE for at least one row produced by the subquery.\n IN evaluates to FALSE if the subquery returns no rows.\n\nDespite this logical equivalence, the optimizer applies additional transformations to IN subqueries (such as semi-joins) that do not always apply to other quantitative ANY comparisons like > ANY or <= SOME.\n\nHandling NULL Values\n\nThe behavior of IN and NOT IN follows SQL three-valued logic.\n\n Source Expression is NULL: If the scalar_expression is NULL, the result is NULL.\n Subquery Contains NULL (IN): If no match is found and the subquery contains at least one NULL, the result is NULL.\n Subquery Contains NULL (NOT IN): If the subquery returns any NULL value, NOT IN will always evaluate to NULL or FALSE, never TRUE, even if no matching non-null value exists.\n\nAvoid using NOT IN if the subquery columns can contain NULL values. In such cases, NOT EXISTS is generally safer and more predictable.\n\nNOT IN vs. <> ANY\n\nNOT IN and <> ANY are not synonyms and represent different logical tests:\n\n| OperatorText | Logical MeaningText                                         | ResultText                                                                               |\n| ------------ | ----------------------------------------------------------- | ---------------------------------------------------------------------------------------- |\n| NOT IN     | "Is this value absent from the entire set?"                 | Returns TRUE only if the value matches no rows in the subquery.                        |\n| <> ANY     | "Is there at least one value in the set that is different?" | Returns TRUE if there is at least one row in the subquery that differs from the value. |\n\nOptimization and Performance\n\nMariaDB treats IN` subqueries as high-priority candidates for specific optimizations, including:\n\n Semi-join transformations: Converting the subquery into a join to improve execution speed.\n Subquery materialization: Storing the subquery result in a temporary internal table to avoid repeated execution.\n IN-to-EXISTS rewrites: Converting the predicate based on cost estimates.\n\nExamples\n--------\n\nSELECT * FROM sq1 WHERE num1 IN (SELECT num2 FROM sq2);\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/subqueries/subqueries-with-in-and-not-in', '', 'https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/subqueries/subqueries-with-in-and-not-in');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (697, 34, 'BUFFER', 'Description\n-----------\n\nA synonym for ST_BUFFER.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-constructors/buffer', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-constructors/buffer');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (698, 34, 'CONVEXHULL', 'Description\n-----------\n\nA synonym for ST_CONVEXHULL.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-constructors/convexhull', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-constructors/convexhull');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (699, 34, 'ST\\_AsGeoJSON', 'Syntax\n------\n\nST_AsGeoJSON(g[, max_decimals[, options]])\n\nDescription\n-----------\n\nReturns the given geometry _g_ as a GeoJSON element. The optional _max_decimals_ limits the maximum number of decimals displayed.\n\nThe optional _options_ flag can be set to 1 to add a bounding box to the output.\n\nExamples\n--------\n\nSELECT ST_AsGeoJSON(ST_GeomFromText(''POINT(5.3 7.2)''));\n+-------------------------------------------------+\n| ST_AsGeoJSON(ST_GeomFromText(''POINT(5.3 7.2)'')) |\n+-------------------------------------------------+\n| {"type": "Point", "coordinates": [5.3, 7.2]}    |\n+-------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-constructors/geojson-st_asgeojson', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-constructors/geojson-st_asgeojson');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (700, 34, 'GEOMETRYCOLLECTION', 'Syntax\n------\n\nGeometryCollection(g1,g2,...)\n\nDescription\n-----------\n\nConstructs a WKB GeometryCollection. If any argument is not a well-formed WKB representation of a geometry, the return value is NULL.\n\nExamples\n--------\n\nCREATE TABLE gis_geometrycollection  (g GEOMETRYCOLLECTION);\nSHOW FIELDS FROM gis_geometrycollection;\nINSERT INTO gis_geometrycollection VALUES\n    (GeomCollFromText(''GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))'')),\n    (GeometryFromWKB(AsWKB(GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9)))))),\n    (GeomFromText(''GeometryCollection()'')),\n    (GeomFromText(''GeometryCollection EMPTY''));\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-constructors/geometrycollection', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-constructors/geometrycollection');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (701, 34, 'LINESTRING', 'Syntax\n------\n\nLineString(pt1,pt2,...)\n\nDescription\n-----------\n\nWKB LineString from WKB Point coordinate data.\\\nConstructs a WKB LineString value from a number of WKB Point arguments. If any argument is not a WKB Point, the return value isNULL. If the number of Point arguments is less than two, the return value is NULL.\n\nExamples\n--------\n\nSET @ls = ''LineString(1 1,2 2,3 3)'';\n\nSELECT AsText(EndPoint(GeomFromText(@ls)));\n+-------------------------------------+\n| AsText(EndPoint(GeomFromText(@ls))) |\n+-------------------------------------+\n| POINT(3 3)                          |\n+-------------------------------------+\n\nCREATE TABLE gis_line  (g LINESTRING);\nINSERT INTO gis_line VALUES\n    (LineFromText(''LINESTRING(0 0,0 10,10 0)'')),\n    (LineStringFromText(''LINESTRING(10 10,20 10,20 20,10 20,10 10)'')),\n    (LineStringFromWKB(AsWKB(LineString(Point(10, 10), Point(40, 10)))));\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-constructors/linestring', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-constructors/linestring');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (702, 34, 'MULTILINESTRING', 'Syntax\n------\n\nMultiLineString(ls1,ls2,...)\n\nDescription\n-----------\n\nConstructs a WKB MultiLineString value using WKB LineString arguments. If any argument is not a WKB LineString, the return value isNULL.\n\nExamples\n--------\n\nCREATE TABLE gis_multi_line (g MULTILINESTRING);\nINSERT INTO gis_multi_line VALUES\n (MultiLineStringFromText(''MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))'')),\n (MLineFromText(''MULTILINESTRING((10 48,10 21,10 0))'')),\n (MLineFromWKB(AsWKB(MultiLineString(LineString(Point(1, 2), \n    Point(3, 5)), LineString(Point(2, 5),Point(5, 8),Point(21, 7))))));\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-constructors/multilinestring', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-constructors/multilinestring');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (703, 34, 'MULTIPOINT', 'Syntax\n------\n\nMultiPoint(pt1,pt2,...)\n\nDescription\n-----------\n\nConstructs a WKB MultiPoint value using WKB Point arguments. If any argument is not a WKB Point, the return value is NULL.\n\nExamples\n--------\n\nSET @g = ST_GEOMFROMTEXT(''MultiPoint( 1 1, 2 2, 5 3, 7 2, 9 3, 8 4, 6 6, 6 9, 4 9, 1 5 )'');\n\nCREATE TABLE gis_multi_point (g MULTIPOINT);\nINSERT INTO gis_multi_point VALUES\n    (MultiPointFromText(''MULTIPOINT(0 0,10 10,10 20,20 20)'')),\n    (MPointFromText(''MULTIPOINT(1 1,11 11,11 21,21 21)'')),\n    (MPointFromWKB(AsWKB(MultiPoint(Point(3, 6), Point(4, 10)))));\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-constructors/multipoint', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-constructors/multipoint');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (704, 34, 'MULTIPOLYGON', 'Syntax\n------\n\nMultiPolygon(poly1,poly2,...)\n\nDescription\n-----------\n\nConstructs a WKB MultiPolygon value from a set of WKB Polygon arguments. If any argument is not a WKB Polygon, the return value is NULL.\n\nExamples\n--------\n\nCREATE TABLE gis_multi_polygon  (g MULTIPOLYGON);\nINSERT INTO gis_multi_polygon VALUES\n    (MultiPolygonFromText(''MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),\n     ((59 18,67 18,67 13,59 13,59 18)))'')),\n    (MPolyFromText(''MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),\n        ((59 18,67 18,67 13,59 13,59 18)))'')),\n    (MPolyFromWKB(AsWKB(MultiPolygon(Polygon(LineString(\n       Point(0, 3), Point(3, 3), Point(3, 0), Point(0, 3)))))));\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-constructors/multipolygon', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-constructors/multipolygon');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (705, 34, 'POINT', 'Syntax\n------\n\nPoint(x,y)\n\nDescription\n-----------\n\nConstructs a WKB Point using the given coordinates.\n\nExamples\n--------\n\nSET @g = ST_GEOMFROMTEXT(''Point(1 1)'');\n\nCREATE TABLE gis_point  (g POINT);\nINSERT INTO gis_point VALUES\n    (PointFromText(''POINT(10 10)'')),\n    (PointFromText(''POINT(20 10)'')),\n    (PointFromText(''POINT(20 20)'')),\n    (PointFromWKB(AsWKB(PointFromText(''POINT(10 20)''))));\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-constructors/point', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-constructors/point');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (706, 34, 'PointOnSurface', 'Description\n-----------\n\nA synonym for ST_PointOnSurface.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-constructors/pointonsurface', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-constructors/pointonsurface');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (707, 34, 'POLYGON', 'Syntax\n------\n\nPolygon(ls1,ls2,...)\n\nDescription\n-----------\n\nConstructs a WKB Polygon value from a number of WKB LineString\\\narguments. If any argument does not represent the WKB of a LinearRing (that is,\\\nnot a closed and simple LineString) the return value is NULL.\n\nNote that according to the OpenGIS standard, a POLYGON should have exactly one ExteriorRing and all other rings should lie within that ExteriorRing and thus be the InteriorRings. Practically, however, some systems, including MariaDB''s, permit polygons to have several ''ExteriorRings''. In the case of there being multiple, non-overlapping exterior rings ST_NUMINTERIORRINGS() will return 1.\n\nExamples\n--------\n\nSET @g = ST_GEOMFROMTEXT(''POLYGON((1 1,1 5,4 9,6 9,9 3,7 2,1 1))'');\n\nCREATE TABLE gis_polygon   (g POLYGON);\nINSERT INTO gis_polygon VALUES\n    (PolygonFromText(''POLYGON((10 10,20 10,20 20,10 20,10 10))'')),\n    (PolyFromText(''POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))'')),\n    (PolyFromWKB(AsWKB(Polygon(LineString(Point(0, 0), Point(30, 0), Point(30, 30), Point(0, 0))))));\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-constructors/polygon', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-constructors/polygon');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (708, 34, 'ST\\_BUFFER', 'Syntax\n------\n\nST_BUFFER(g1,r)\nBUFFER(g1,r)\n\nDescription\n-----------\n\nReturns a geometry that represents all points whose distance from geometry _g1_ is less than or equal to distance, or radius, _r_.\n\nUses for this function could include creating for example a new geometry representing a buffer zone around an island.\n\nBUFFER() is a synonym.\n\nExamples\n--------\n\nSET @g1 = ST_GEOMFROMTEXT(''POLYGON((10 10, 10 20, 20 20, 20 10, 10 10))'');\n\nSET @g2 = ST_GEOMFROMTEXT(''POINT(8 8)'');\n\nSELECT ST_WITHIN(@g2,ST_BUFFER(@g1,5));\n+---------------------------------+\n| ST_WITHIN(@g2,ST_BUFFER(@g1,5)) |\n+---------------------------------+\n|                               1 |\n+---------------------------------+\n\nSELECT ST_WITHIN(@g2,ST_BUFFER(@g1,1));\n+---------------------------------+\n| ST_WITHIN(@g2,ST_BUFFER(@g1,1)) |\n+---------------------------------+\n|                               0 |\n+---------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-constructors/st_buffer', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-constructors/st_buffer');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (709, 34, 'ST\\_CONVEXHULL', 'Syntax\n------\n\nST_ConvexHull(g)\nConvexHull(g)\n\nDescription\n-----------\n\nGiven a geometry, returns a geometry that is the minimum convex geometry enclosing all geometries within the set. Returns NULL if the geometry value is NULL or an empty value.\n\nST_ConvexHull() and ConvexHull() are synonyms.\n\nExamples\n--------\n\nSET @g = ST_GEOMFROMTEXT(''Point(0 0)'');\n\nSELECT ST_ASTEXT(ST_CONVEXHULL(@g));\n+------------------------------+\n| ST_ASTEXT(ST_CONVEXHULL(@g)) |\n+------------------------------+\n| POINT(0 0)                   |\n+------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-constructors/st_convexhull', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-constructors/st_convexhull');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (710, 34, 'ST\\_GeomFromGeoJSON', 'Syntax\n------\n\nST_GeomFromGeoJSON(g[, option])\n\nDescription\n-----------\n\nGiven a GeoJSON input _g_, returns a geometry object. The _option_ specifies what to do if _g_ contains geometries with coordinate dimensions higher than 2.\n\n| Option | Description                                                                                      |\n| ------ | ------------------------------------------------------------------------------------------------ |\n| 1      | Return an error (the default)                                                                    |\n| 2 - 4  | The document is accepted, but the coordinates for higher coordinate dimensions are stripped off. |\n\nExamples\n--------\n\nSET @j = ''{ "type": "Point", "coordinates": [5.3, 15.0]}'';\n\nSELECT ST_AsText(ST_GeomFromGeoJSON(@j));\n+-----------------------------------+\n| ST_AsText(ST_GeomFromGeoJSON(@j)) |\n+-----------------------------------+\n| POINT(5.3 15)                     |\n+-----------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-constructors/st_geomfromgeojson', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-constructors/st_geomfromgeojson');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (711, 34, 'ST\\_INTERSECTION', 'Syntax\n------\n\nST_INTERSECTION(g1,g2)\n\nDescription\n-----------\n\nReturns a geometry that is the intersection, or shared portion, of geometry _g1_ and geometry _g2_.\n\nExamples\n--------\n\nSET @g1 = ST_GEOMFROMTEXT(''POINT(2 1)'');\n\nSET @g2 = ST_GEOMFROMTEXT(''LINESTRING(2 1, 0 2)'');\n\nSELECT ASTEXT(ST_INTERSECTION(@g1,@g2));\n+----------------------------------+\n| ASTEXT(ST_INTERSECTION(@g1,@g2)) |\n+----------------------------------+\n| POINT(2 1)                       |\n+----------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-constructors/st_intersection', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-constructors/st_intersection');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (712, 34, 'ST\\_POINTONSURFACE', 'Syntax\n------\n\nST_PointOnSurface(g)\nPointOnSurface(g)\n\nDescription\n-----------\n\nGiven a geometry, returns a POINT guaranteed to intersect a surface. However, see MDEV-7514.\n\nST_PointOnSurface() and PointOnSurface() are synonyms.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-constructors/st_pointonsurface', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-constructors/st_pointonsurface');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (713, 34, 'ST\\_SYMDIFFERENCE', 'Syntax\n------\n\nST_SYMDIFFERENCE(g1,g2)\n\nDescription\n-----------\n\nReturns a geometry that represents the portions of geometry _g1_ and geometry _g2_ that don''t intersect.\n\nExamples\n--------\n\nSET @g1 = ST_GEOMFROMTEXT(''LINESTRING(10 20, 10 40)'');\n\nSET @g2 = ST_GEOMFROMTEXT(''LINESTRING(10 15, 10 25)'');\n\nSELECT ASTEXT(ST_SYMDIFFERENCE(@g1,@g2));\n+----------------------------------------------+\n| ASTEXT(ST_SYMDIFFERENCE(@g1,@g2))            |\n+----------------------------------------------+\n| MULTILINESTRING((10 15,10 20),(10 25,10 40)) |\n+----------------------------------------------+\n\nSET @g2 = ST_GeomFromText(''LINESTRING(10 20, 10 41)'');\n\nSELECT ASTEXT(ST_SYMDIFFERENCE(@g1,@g2));\n+-----------------------------------+\n| ASTEXT(ST_SYMDIFFERENCE(@g1,@g2)) |\n+-----------------------------------+\n| LINESTRING(10 40,10 41)           |\n+-----------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-constructors/st_symdifference', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-constructors/st_symdifference');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (714, 34, 'ST\\_UNION', 'Syntax\n------\n\nST_UNION(g1,g2)\n\nDescription\n-----------\n\nReturns a geometry that is the union of the geometry _g1_ and geometry _g2_.\n\nExamples\n--------\n\nSET @g1 = GEOMFROMTEXT(''POINT (0 2)'');\n\nSET @g2 = GEOMFROMTEXT(''POINT (2 0)'');\n\nSELECT ASTEXT(ST_UNION(@g1,@g2));\n+---------------------------+\n| ASTEXT(ST_UNION(@g1,@g2)) |\n+---------------------------+\n| MULTIPOINT(2 0,0 2)       |\n+---------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-constructors/st_union', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-constructors/st_union');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (715, 34, 'DIMENSION', 'Description\n-----------\n\nA synonym for ST_DIMENSION.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/dimension', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/dimension');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (716, 34, 'BOUNDARY', 'Description\n-----------\n\nA synonym for ST_BOUNDARY.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/geometry-properties-boundary', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/geometry-properties-boundary');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (717, 34, 'ENVELOPE', 'Description\n-----------\n\nA synonym for ST_ENVELOPE.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/geometry-properties-envelope', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/geometry-properties-envelope');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (718, 34, 'GeometryN', 'Description\n-----------\n\nA synonym for ST_GeometryN.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/geometry-properties-geometryn', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/geometry-properties-geometryn');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (719, 34, 'GeometryType', 'Description\n-----------\n\nA synonym for ST_GeometryType.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/geometry-properties-geometrytype', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/geometry-properties-geometrytype');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (720, 34, 'IsEmpty', 'Description\n-----------\n\nA synonym for ST_IsEmpty.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/geometry-properties-isempty', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/geometry-properties-isempty');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (721, 34, 'IsSimple', 'Description\n-----------\n\nA synonym for ST_IsSImple.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/geometry-properties-issimple', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/geometry-properties-issimple');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (722, 34, 'NumGeometries', 'Description\n-----------\n\nA synonym for ST_NumGeometries.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/geometry-properties-numgeometries', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/geometry-properties-numgeometries');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (723, 34, 'SRID', 'Description\n-----------\n\nA synonym for ST_SRID.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/geometry-properties-srid', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/geometry-properties-srid');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (724, 34, 'IsClosed', 'Description\n-----------\n\nA synonym for ST_IsClosed.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/isclosed', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/isclosed');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (725, 34, 'IsRing', 'Description\n-----------\n\nA synonym for ST_IsRing.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/isring', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/isring');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (726, 34, 'ST\\_BOUNDARY', 'Syntax\n------\n\nST_BOUNDARY(g)\nBOUNDARY(g)\n\nDescription\n-----------\n\nReturns a geometry that is the closure of the combinatorial boundary of the geometry value _g_.\n\nBOUNDARY() is a synonym.\n\nExamples\n--------\n\nSELECT ST_AsText(ST_Boundary(ST_GeomFromText(''LINESTRING(3 3,0 0, -3 3)'')));\n+----------------------------------------------------------------------+\n| ST_AsText(ST_Boundary(ST_GeomFromText(''LINESTRING(3 3,0 0, -3 3)''))) |\n+----------------------------------------------------------------------+\n| MULTIPOINT(3 3,-3 3)                                                 |\n+----------------------------------------------------------------------+\n\nSELECT ST_AsText(ST_Boundary(ST_GeomFromText(''POLYGON((3 3,0 0, -3 3, 3 3))'')));\n+--------------------------------------------------------------------------+\n| ST_AsText(ST_Boundary(ST_GeomFromText(''POLYGON((3 3,0 0, -3 3, 3 3))''))) |\n+--------------------------------------------------------------------------+\n| LINESTRING(3 3,0 0,-3 3,3 3)                                             |\n+--------------------------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/st_boundary', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/st_boundary');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (727, 34, 'ST\\_DIMENSION', 'Syntax\n------\n\nST_Dimension(g)\nDimension(g)\n\nDescription\n-----------\n\nReturns the inherent dimension of the geometry value _g_. The result can\\\nbe\n\n| Dimension | Definition                               |\n| --------- | ---------------------------------------- |\n| -1        | empty geometry                           |\n| 0         | geometry with no length or area          |\n| 1         | geometry with no area but nonzero length |\n| 2         | geometry with nonzero area               |\n\nST_Dimension() and Dimension() are synonyms.\n\nExamples\n--------\n\nSELECT Dimension(GeomFromText(''LineString(1 1,2 2)''));\n+------------------------------------------------+\n| Dimension(GeomFromText(''LineString(1 1,2 2)'')) |\n+------------------------------------------------+\n|                                              1 |\n+------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/st_dimension', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/st_dimension');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (728, 34, 'ST\\_ENVELOPE', 'Syntax\n------\n\nST_ENVELOPE(g)\nENVELOPE(g)\n\nDescription\n-----------\n\nReturns the Minimum Bounding Rectangle (MBR) for the geometry value g. The result is returned as a Polygon value.\n\nThe polygon is defined by the corner points of the bounding box:\n\n``\nPOLYGON((MINX MINY, MAXX MINY, MAXX MAXY, MINX MAXY, MINX MINY))\n`\n\nST_ENVELOPE() and ENVELOPE()` are synonyms.\n\nExamples\n--------\n\nSELECT AsText(ST_ENVELOPE(GeomFromText(''LineString(1 1,4 4)'')));\n+----------------------------------------------------------+\n| AsText(ST_ENVELOPE(GeomFromText(''LineString(1 1,4 4)''))) |\n+----------------------------------------------------------+\n| POLYGON((1 1,4 1,4 4,1 4,1 1))                           |\n+----------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/st_envelope', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/st_envelope');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (729, 34, 'ST\\_GEOMETRYN', 'Syntax\n------\n\nST_GeometryN(gc,N)\nGeometryN(gc,N)\n\nDescription\n-----------\n\nReturns the N-th geometry in the GeometryCollection _gc._ Geometries are numbered beginning with 1.\n\nST_GeometryN() and GeometryN() are synonyms.\n\nExamples\n--------\n\nSET @gc = ''GeometryCollection(Point(1 1),LineString(12 14, 9 11))'';\n\nSELECT AsText(GeometryN(GeomFromText(@gc),1));\n+----------------------------------------+\n| AsText(GeometryN(GeomFromText(@gc),1)) |\n+----------------------------------------+\n| POINT(1 1)                             |\n+----------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/st_geometryn', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/st_geometryn');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (730, 34, 'ST\\_GEOMETRYTYPE', 'Syntax\n------\n\nST_GeometryType(g)\nGeometryType(g)\n\nDescription\n-----------\n\nReturns as a string the name of the geometry type of which the geometry instance g is a member. The name corresponds to one of the instantiable Geometry subclasses.\n\nST_GeometryType() and GeometryType() are synonyms.\n\nExamples\n--------\n\nSELECT GeometryType(GeomFromText(''POINT(1 1)''));\n+------------------------------------------+\n| GeometryType(GeomFromText(''POINT(1 1)'')) |\n+------------------------------------------+\n| POINT                                    |\n+------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/st_geometrytype', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/st_geometrytype');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (731, 34, 'ST\\_ISCLOSED', 'Syntax\n------\n\nST_IsClosed(g)\nIsClosed(g)\n\nDescription\n-----------\n\nReturns 1 if a given LINESTRING''s start and end points are the same, or 0 if they are not the same.\n\nST_IsClosed() and IsClosed() are synonyms.\n\nExamples\n--------\n\nSET @ls = ''LineString(0 0, 0 4, 4 4, 0 0)'';\nSELECT ST_ISCLOSED(GEOMFROMTEXT(@ls));\n+--------------------------------+\n| ST_ISCLOSED(GEOMFROMTEXT(@ls)) |\n+--------------------------------+\n|                              1 |\n+--------------------------------+\n\nSET @ls = ''LineString(0 0, 0 4, 4 4, 0 1)'';\nSELECT ST_ISCLOSED(GEOMFROMTEXT(@ls));\n+--------------------------------+\n| ST_ISCLOSED(GEOMFROMTEXT(@ls)) |\n+--------------------------------+\n|                              0 |\n+--------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/st_isclosed', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/st_isclosed');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (732, 34, 'ST\\_ISEMPTY', 'Syntax\n------\n\nST_IsEmpty(g)\nIsEmpty(g)\n\nDescription\n-----------\n\nIsEmpty is a function defined by the OpenGIS specification, but is not fully implemented by MariaDB or MySQL.\n\nSince MariaDB and MySQL do not support GIS EMPTY values such as POINT EMPTY, as implemented it simply returns 1 if the geometry value _g_ is invalid, 0 if it is valid, and NULL if the argument is NULL.\n\nST_IsEmpty() and IsEmpty() are synonyms.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/st_isempty', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/st_isempty');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (733, 34, 'ST\\_IsRing', 'Syntax\n------\n\nST_IsRing(g)\nIsRing(g)\n\nDescription\n-----------\n\nReturns true if a given LINESTRING is a ring, that is, both ST_IsClosed and ST_IsSimple. A simple curve does not pass through the same point more than once. However, see MDEV-7510.\n\nSt_IsRing() and IsRing() are synonyms.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/st_isring', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/st_isring');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (734, 34, 'ST\\_IsSimple', 'Syntax\n------\n\nST_IsSimple(g)\nIsSimple(g)\n\nDescription\n-----------\n\nReturns true if the given Geometry has no anomalous geometric points, false if it does, or NULL if given a NULL value.\n\nST_IsSimple() and IsSimple() are synonyms.\n\nExamples\n--------\n\nSET @g = ''Point(1 2)'';\n\nSELECT ST_ISSIMPLE(GEOMFROMTEXT(@g));\n+-------------------------------+\n| ST_ISSIMPLE(GEOMFROMTEXT(@g)) |\n+-------------------------------+\n|                             1 |\n+-------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/st_issimple', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/st_issimple');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (735, 34, 'ST\\_NUMGEOMETRIES', 'Syntax\n------\n\nST_NumGeometries(gc)\nNumGeometries(gc)\n\nDescription\n-----------\n\nReturns the number of geometries in the GeometryCollection gc.\n\nST_NumGeometries() and NumGeometries() are synonyms.\n\nExamples\n--------\n\nSET @gc = ''GeometryCollection(Point(1 1),LineString(2 2, 3 3))'';\n\nSELECT NUMGEOMETRIES(GeomFromText(@gc));\n+----------------------------------+\n| NUMGEOMETRIES(GeomFromText(@gc)) |\n+----------------------------------+\n|                                2 |\n+----------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/st_numgeometries', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/st_numgeometries');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (736, 34, 'ST\\_RELATE', 'Syntax\n------\n\nST_Relate(g1, g2, i)\n\nDescription\n-----------\n\nReturns true if Geometry g1 is spatially related to Geometryg2 by testing for intersections between the interior, boundary and exterior of the two geometries as specified by the values in intersection matrix pattern i.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/st_relate', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/st_relate');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (737, 34, 'ST\\_SRID', 'Syntax\n------\n\nST_SRID(g)\nSRID(g)\n\nDescription\n-----------\n\nReturns an integer indicating the Spatial Reference System ID for the geometry value g.\n\nIn MariaDB, the SRID value is just an integer associated with the geometry value. All calculations are done assuming Euclidean (planar) geometry.\n\nST_SRID() and SRID() are synonyms.\n\nExamples\n--------\n\nSELECT SRID(GeomFromText(''LineString(1 1,2 2)'',101));\n+-----------------------------------------------+\n| SRID(GeomFromText(''LineString(1 1,2 2)'',101)) |\n+-----------------------------------------------+\n|                                           101 |\n+-----------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/st_srid', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-properties/st_srid');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (738, 34, 'CONTAINS', 'Syntax\n------\n\nContains(g1,g2)\n\nDescription\n-----------\n\nReturns 1 or 0 to indicate whether a geometry g1 completely contains geometry g2. CONTAINS() is based on the original MySQL implementation and uses object bounding rectangles, while ST_CONTAINS() uses object shapes.\n\nThis tests the opposite relationship to Within().\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-relations/contains', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-relations/contains');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (739, 34, 'CROSSES', 'Syntax\n------\n\nCrosses(g1,g2)\n\nDescription\n-----------\n\nReturns 1 if g1 spatially crosses g2. Returns NULL if g1 is a Polygon or a MultiPolygon, or if g2 is a Point or a MultiPoint. Otherwise, returns 0.\n\nThe term spatially crosses denotes a spatial relation between two given geometries that has the following properties:\n\n The two geometries intersect.\n Their intersection results in a geometry that has a dimension that is one less than the maximum dimension of the two given geometries.\n* Their intersection is not equal to either of the two given geometries.\n\nCROSSES() is based on the original MySQL implementation, and uses object bounding rectangles, while ST_CROSSES() uses object shapes.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-relations/crosses', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-relations/crosses');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (740, 34, 'DISJOINT', 'Syntax\n------\n\nDisjoint(g1,g2)\n\nDescription\n-----------\n\nReturns 1 or 0 to indicate whether g1 is spatially disjoint from (does not intersect) g2.\n\nDISJOINT() tests the opposite relationship to INTERSECTS().\n\nDISJOINT() is based on the original MySQL implementation and uses object bounding rectangles, while ST_DISJOINT() uses object shapes.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-relations/disjoint', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-relations/disjoint');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (741, 34, 'EQUALS', 'Syntax\n------\n\nMBREQUALS(g1,g2)\n\nDescription\n-----------\n\nReturns 1 or 0 to indicate whether _g1_ is spatially equal to _g2_.\n\nEQUALS() is based on the original MySQL implementation and uses object bounding rectangles, while ST_EQUALS() uses object shapes.\n\nMBREQUALS is a synonym for Equals.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-relations/equals', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-relations/equals');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (742, 34, 'INTERSECTS', 'Syntax\n------\n\nINTERSECTS(g1,g2)\n\nDescription\n-----------\n\nReturns 1 or 0 to indicate whether geometry _g1_ spatially intersects geometry _g2_.\n\nINTERSECTS() is based on the original MySQL implementation and uses object bounding rectangles, while ST_INTERSECTS() uses object shapes.\n\nINTERSECTS() tests the opposite relationship to DISJOINT().\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-relations/intersects', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-relations/intersects');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (743, 34, 'OVERLAPS', 'Syntax\n------\n\nOVERLAPS(g1,g2)\n\nDescription\n-----------\n\nReturns 1 or 0 to indicate whether g1 spatially overlaps g2.\\\nThe term spatially overlaps is used if two geometries of equal dimensions intersect and their intersection results in a geometry of the same dimension but not equal to either of the given geometries.\n\nOVERLAPS() is based on the original MySQL implementation and uses object bounding rectangles, while ST_OVERLAPS() uses object shapes.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-relations/overlaps', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-relations/overlaps');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (744, 34, 'ST\\_CONTAINS', 'Syntax\n------\n\nST_CONTAINS(g1,g2)\n\nDescription\n-----------\n\nReturns 1 or 0 to indicate whether a geometry g1 completely contains geometry g2.\n\nST_CONTAINS() uses object shapes, while CONTAINS(), based on the original MySQL implementation, uses object bounding rectangles.\n\nST_CONTAINS tests the opposite relationship to ST_WITHIN().\n\nExamples\n--------\n\nSET @g1 = ST_GEOMFROMTEXT(''POLYGON((175 150, 20 40, 50 60, 125 100, 175 150))'');\n\nSET @g2 = ST_GEOMFROMTEXT(''POINT(174 149)'');\n\nSELECT ST_CONTAINS(@g1,@g2);\n+----------------------+\n| ST_CONTAINS(@g1,@g2) |\n+----------------------+\n|                    1 |\n+----------------------+\n\nSET @g2 = ST_GEOMFROMTEXT(''POINT(175 151)'');\n\nSELECT ST_CONTAINS(@g1,@g2);\n+----------------------+\n| ST_CONTAINS(@g1,@g2) |\n+----------------------+\n|                    0 |\n+----------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-relations/st-contains', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-relations/st-contains');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (745, 34, 'ST\\_CROSSES', 'Syntax\n------\n\nST_CROSSES(g1,g2)\n\nDescription\n-----------\n\nReturns 1 if geometry _g1_ spatially crosses geometry _g2_. Returns NULL if g1 is a Polygon or a MultiPolygon, or if g2 is a Point or a MultiPoint. Otherwise, returns 0.\n\nThe term spatially crosses denotes a spatial relation between two given geometries that has the following properties:\n\n The two geometries intersect.\n Their intersection results in a geometry that has a dimension that is one less than the maximum dimension of the two given geometries.\n* Their intersection is not equal to either of the two given geometries.\n\nST_CROSSES() uses object shapes, while CROSSES(), based on the original MySQL implementation, uses object bounding rectangles.\n\nExamples\n--------\n\nSET @g1 = ST_GEOMFROMTEXT(''LINESTRING(174 149, 176 151)'');\n\nSET @g2 = ST_GEOMFROMTEXT(''POLYGON((175 150, 20 40, 50 60, 125 100, 175 150))'');\n\nSELECT ST_CROSSES(@g1,@g2);\n+---------------------+\n| ST_CROSSES(@g1,@g2) |\n+---------------------+\n|                   1 |\n+---------------------+\n\nSET @g1 = ST_GEOMFROMTEXT(''LINESTRING(176 149, 176 151)'');\n\nSELECT ST_CROSSES(@g1,@g2);\n+---------------------+\n| ST_CROSSES(@g1,@g2) |\n+---------------------+\n|                   0 |\n+---------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-relations/st-crosses', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-relations/st-crosses');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (746, 34, 'ST\\_EQUALS', 'Syntax\n------\n\nST_EQUALS(g1,g2)\n\nDescription\n-----------\n\nReturns 1 or 0 to indicate whether geometry _g1_ is spatially equal to geometry _g2_.\n\nST_EQUALS() uses object shapes, while EQUALS(), based on the original MySQL implementation, uses object bounding rectangles.\n\nExamples\n--------\n\nSET @g1 = ST_GEOMFROMTEXT(''LINESTRING(174 149, 176 151)'');\n\nSET @g2 = ST_GEOMFROMTEXT(''LINESTRING(176 151, 174 149)'');\n\nSELECT ST_EQUALS(@g1,@g2);\n+--------------------+\n| ST_EQUALS(@g1,@g2) |\n+--------------------+\n|                  1 |\n+--------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-relations/st-equals', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-relations/st-equals');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (747, 34, 'ST\\_INTERSECTS', 'Syntax\n------\n\nST_INTERSECTS(g1,g2)\n\nDescription\n-----------\n\nReturns 1 or 0 to indicate whether geometry _g1_ spatially intersects geometry _g2_.\n\nST_INTERSECTS() uses object shapes, while INTERSECTS(), based on the original MySQL implementation, uses object bounding rectangles.\n\nST_INTERSECTS() tests the opposite relationship to ST_DISJOINT().\n\nExamples\n--------\n\nSET @g1 = ST_GEOMFROMTEXT(''POINT(0 0)'');\n\nSET @g2 = ST_GEOMFROMTEXT(''LINESTRING(0 0, 0 2)'');\n\nSELECT ST_INTERSECTS(@g1,@g2);\n+------------------------+\n| ST_INTERSECTS(@g1,@g2) |\n+------------------------+\n|                      1 |\n+------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-relations/st-intersects', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-relations/st-intersects');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (748, 34, 'ST\\_OVERLAPS', 'Syntax\n------\n\nST_OVERLAPS(g1,g2)\n\nDescription\n-----------\n\nReturns 1 or 0 to indicate whether geometry _g1_ spatially overlaps geometry _g2_.\n\nThe term spatially overlaps is used if two geometries of equal dimensions intersect and their\\\nintersection results in a geometry of the same dimension but not equal to either of the given geometries.\n\nST_OVERLAPS() uses object shapes, while OVERLAPS(), based on the original MySQL implementation, uses object bounding rectangles.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-relations/st-overlaps', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-relations/st-overlaps');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (749, 34, 'ST\\_TOUCHES', 'Syntax\n------\n\nST_TOUCHES(g1,g2)\n\nDescription\n-----------\n\nReturns 1 or 0 to indicate whether geometry _g1_ spatially touches geometry _g2_. Two geometries spatially touch if the interiors of the geometries do not intersect, but the boundary of one of the geometries intersects either the boundary or the interior of the other.\n\nST_TOUCHES() uses object shapes, while TOUCHES(), based on the original MySQL implementation, uses object bounding rectangles.\n\nExamples\n--------\n\nSET @g1 = ST_GEOMFROMTEXT(''POINT(2 0)'');\n\nSET @g2 = ST_GEOMFROMTEXT(''LINESTRING(2 0, 0 2)'');\n\nSELECT ST_TOUCHES(@g1,@g2);\n+---------------------+\n| ST_TOUCHES(@g1,@g2) |\n+---------------------+\n|                   1 |\n+---------------------+\n\nSET @g1 = ST_GEOMFROMTEXT(''POINT(2 1)'');\n\nSELECT ST_TOUCHES(@g1,@g2);\n+---------------------+\n| ST_TOUCHES(@g1,@g2) |\n+---------------------+\n|                   0 |\n+---------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-relations/st-touches', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-relations/st-touches');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (750, 34, 'ST\\_WITHIN', 'Syntax\n------\n\nST_WITHIN(g1,g2)\n\nDescription\n-----------\n\nReturns 1 or 0 to indicate whether geometry _g1_ is spatially within geometry _g2_.\n\nThis tests the opposite relationship as ST_CONTAINS().\n\nST_WITHIN() uses object shapes, while WITHIN(), based on the original MySQL implementation, uses object bounding rectangles.\n\nExamples\n--------\n\nSET @g1 = ST_GEOMFROMTEXT(''POINT(174 149)'');\n\nSET @g2 = ST_GEOMFROMTEXT(''POLYGON((175 150, 20 40, 50 60, 125 100, 175 150))'');\n\nSELECT ST_WITHIN(@g1,@g2);\n+--------------------+\n| ST_WITHIN(@g1,@g2) |\n+--------------------+\n|                  1 |\n+--------------------+\n\nSET @g1 = ST_GEOMFROMTEXT(''POINT(176 151)'');\n\nSELECT ST_WITHIN(@g1,@g2);\n+--------------------+\n| ST_WITHIN(@g1,@g2) |\n+--------------------+\n|                  0 |\n+--------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-relations/st-within', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-relations/st-within');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (751, 34, 'ST\\_DIFFERENCE', 'Syntax\n------\n\nST_DIFFERENCE(g1,g2)\n\nDescription\n-----------\n\nReturns a geometry representing the point set difference of the given geometry values.\n\nExamples\n--------\n\nSET @g1 = POINT(10,10), @g2 = POINT(20,20);\n\nSELECT ST_AsText(ST_Difference(@g1, @g2));\n+------------------------------------+\n| ST_AsText(ST_Difference(@g1, @g2)) |\n+------------------------------------+\n| POINT(10 10)                       |\n+------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-relations/st_difference', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-relations/st_difference');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (752, 34, 'ST\\_DISJOINT', 'Syntax\n------\n\nST_DISJOINT(g1,g2)\n\nDescription\n-----------\n\nReturns 1 or 0 to indicate whether geometry _g1_ is spatially disjoint from (does not intersect with) geometry _g2_.\n\nST_DISJOINT() uses object shapes, while DISJOINT(), based on the original MySQL implementation, uses object bounding rectangles.\n\nST_DISJOINT() tests the opposite relationship to ST_INTERSECTS().\n\nExamples\n--------\n\nSET @g1 = ST_GEOMFROMTEXT(''POINT(0 0)'');\n\nSET @g2 = ST_GEOMFROMTEXT(''LINESTRING(2 0, 0 2)'');\n\nSELECT ST_DISJOINT(@g1,@g2);\n+----------------------+\n| ST_DISJOINT(@g1,@g2) |\n+----------------------+\n|                    1 |\n+----------------------+\n\nSET @g2 = ST_GEOMFROMTEXT(''LINESTRING(0 0, 0 2)'');\n\nSELECT ST_DISJOINT(@g1,@g2);\n+----------------------+\n| ST_DISJOINT(@g1,@g2) |\n+----------------------+\n|                    0 |\n+----------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-relations/st_disjoint', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-relations/st_disjoint');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (753, 34, 'ST\\_DISTANCE', 'Syntax\n------\n\nST_DISTANCE(g1,g2)\n\nDescription\n-----------\n\nReturns the distance between two geometries, or null if not given valid inputs.\n\nExamples\n--------\n\nSELECT ST_Distance(POINT(1,2),POINT(2,2));\n+------------------------------------+\n| ST_Distance(POINT(1,2),POINT(2,2)) |\n+------------------------------------+\n|                                  1 |\n+------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-relations/st_distance', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-relations/st_distance');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (754, 34, 'ST\\_DISTANCE\\_SPHERE', 'Syntax\n------\n\nST_DISTANCE_SPHERE(g1,g2,[r])\n\nDescription\n-----------\n\nReturns the spherical distance in meters between two geometries (point or multipoint) on a sphere. The optional radius _r_ is in meters, must be positive, and defaults to the Earth''s radius (6370986 meters) if not specified. If either of the two geometries are not valid, NULL is returned.\n\nExamples\n--------\n\nSET @zenica   = ST_GeomFromText(''POINT(17.907743 44.203438)'');\nSET @sarajevo = ST_GeomFromText(''POINT(18.413076 43.856258)'');\nSELECT ST_Distance_Sphere(@zenica, @sarajevo);\n+----------------------------------------+\n| ST_Distance_Sphere(@zenica, @sarajevo) |\n+----------------------------------------+\n|                      55878.59337591705 |\n+----------------------------------------+\n\nSELECT ST_Distance_Sphere(@zenica, @sarajevo, 6370986);\n+-------------------------------------------------+\n| ST_Distance_Sphere(@zenica, @sarajevo, 6370986) |\n+-------------------------------------------------+\n|                               55878.59337591705 |\n+-------------------------------------------------+\n\nSELECT ST_Distance_Sphere(@zenica, @sarajevo, 200);    \n+---------------------------------------------+\n| ST_Distance_Sphere(@zenica, @sarajevo, 200) |\n+---------------------------------------------+\n|                           1.754158410516584 |\n+---------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-relations/st_distance_sphere', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-relations/st_distance_sphere');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (755, 34, 'ST\\_LENGTH', 'Syntax\n------\n\nST_LENGTH(ls)\n\nDescription\n-----------\n\nReturns as a double-precision number the length of the LineString value _ls_ in its associated spatial reference.\n\nExamples\n--------\n\nSET @ls = ''LineString(1 1,2 2,3 3)'';\n\nSELECT ST_LENGTH(ST_GeomFromText(@ls));\n+---------------------------------+\n| ST_LENGTH(ST_GeomFromText(@ls)) |\n+---------------------------------+\n|                2.82842712474619 |\n+---------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-relations/st_length', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-relations/st_length');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (756, 34, 'TOUCHES', 'Syntax\n------\n\nTouches(g1,g2)\n\nDescription\n-----------\n\nReturns 1 or 0 to indicate whether g1 spatially touches g2. Two geometries spatially touch if the interiors of the geometries do not intersect, but the boundary of one of the geometries intersects either the boundary or the interior of the other.\n\nTOUCHES() is based on the original MySQL implementation and uses object bounding rectangles, while ST_TOUCHES() uses object shapes.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-relations/touches', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-relations/touches');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (757, 34, 'WITHIN', 'Syntax\n------\n\nWithin(g1,g2)\n\nDescription\n-----------\n\nReturns 1 or 0 to indicate whether g1 is spatially within g2. This tests the opposite relationship as Contains().\n\nWITHIN() is based on the original MySQL implementation, and uses object bounding rectangles, while ST_WITHIN() uses object shapes.\n\nExamples\n--------\n\nSET @g1 = GEOMFROMTEXT(''POINT(174 149)'');\nSET @g2 = GEOMFROMTEXT(''POINT(176 151)'');\nSET @g3 = GEOMFROMTEXT(''POLYGON((175 150, 20 40, 50 60, 125 100, 175 150))'');\n\nSELECT within(@g1,@g3);\n+-----------------+\n| within(@g1,@g3) |\n+-----------------+\n|               1 |\n+-----------------+\n\nSELECT within(@g2,@g3);\n+-----------------+\n| within(@g2,@g3) |\n+-----------------+\n|               0 |\n+-----------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-relations/within', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/geometry-relations/within');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (758, 34, 'GLENGTH', 'Syntax\n------\n\nGLength(ls)\n\nDescription\n-----------\n\nReturns as a double-precision number the length of the LineString value _ls_ in its associated spatial reference.\n\nExamples\n--------\n\nSET @ls = ''LineString(1 1,2 2,3 3)'';\n\nSELECT GLength(GeomFromText(@ls));\n+----------------------------+\n| GLength(GeomFromText(@ls)) |\n+----------------------------+\n|           2.82842712474619 |\n+----------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/linestring-properties/glength', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/linestring-properties/glength');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (759, 34, 'ENDPOINT', 'Description\n-----------\n\nA synonym for ST_ENDPOINT.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/linestring-properties/linestring-properties-endpoint', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/linestring-properties/linestring-properties-endpoint');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (760, 34, 'NumPoints', 'Description\n-----------\n\nA synonym for ST_NumPoints.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/linestring-properties/linestring-properties-numpoints', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/linestring-properties/linestring-properties-numpoints');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (761, 34, 'PointN', 'Description\n-----------\n\nA synonym for ST_PointN.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/linestring-properties/linestring-properties-pointn', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/linestring-properties/linestring-properties-pointn');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (762, 34, 'STARTPOINT', 'Description\n-----------\n\nA synonym for ST_STARTPOINT.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/linestring-properties/linestring-properties-startpoint', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/linestring-properties/linestring-properties-startpoint');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (763, 34, 'ST\\_ENDPOINT', 'Syntax\n------\n\nST_EndPoint(ls)\nEndPoint(ls)\n\nDescription\n-----------\n\nReturns the Point that is the endpoint of the LineString value ls.\n\nST_EndPoint() and EndPoint() are synonyms.\n\nExamples\n--------\n\nSET @ls = ''LineString(1 1,2 2,3 3)'';\n\nSELECT AsText(EndPoint(GeomFromText(@ls)));\n+-------------------------------------+\n| AsText(EndPoint(GeomFromText(@ls))) |\n+-------------------------------------+\n| POINT(3 3)                          |\n+-------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/linestring-properties/st_endpoint', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/linestring-properties/st_endpoint');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (764, 34, 'ST\\_NUMPOINTS', 'Syntax\n------\n\nST_NumPoints(ls)\nNumPoints(ls)\n\nDescription\n-----------\n\nReturns the number of Point objects in the LineString value ls.\n\nST_NumPoints() and NumPoints() are synonyms.\n\nExamples\n--------\n\nSET @ls = ''LineString(1 1,2 2,3 3)'';\n\nSELECT NumPoints(GeomFromText(@ls));\n+------------------------------+\n| NumPoints(GeomFromText(@ls)) |\n+------------------------------+\n|                            3 |\n+------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/linestring-properties/st_numpoints', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/linestring-properties/st_numpoints');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (765, 34, 'ST\\_POINTN', 'Syntax\n------\n\nST_PointN(ls,N)\nPointN(ls,N)\n\nDescription\n-----------\n\nReturns the N-th Point in the LineString value ls. Points are numbered beginning with 1.\n\nST_PointN() and PointN() are synonyms.\n\nExamples\n--------\n\nSET @ls = ''LineString(1 1,2 2,3 3)'';\n\nSELECT AsText(PointN(GeomFromText(@ls),2));\n+-------------------------------------+\n| AsText(PointN(GeomFromText(@ls),2)) |\n+-------------------------------------+\n| POINT(2 2)                          |\n+-------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/linestring-properties/st_pointn', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/linestring-properties/st_pointn');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (766, 34, 'ST\\_STARTPOINT', 'Syntax\n------\n\nST_StartPoint(ls)\nStartPoint(ls)\n\nDescription\n-----------\n\nReturns the Point that is the start point of the LineString value ls.\n\nST_StartPoint() and StartPoint() are synonyms.\n\nExamples\n--------\n\nSET @ls = ''LineString(1 1,2 2,3 3)'';\n\nSELECT AsText(StartPoint(GeomFromText(@ls)));\n+---------------------------------------+\n| AsText(StartPoint(GeomFromText(@ls))) |\n+---------------------------------------+\n| POINT(1 1)                            |\n+---------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/linestring-properties/st_startpoint', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/linestring-properties/st_startpoint');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (767, 34, 'MBR Definition', 'Description\n-----------\n\nThe MBR (Minimum Bounding Rectangle), or Envelope is the bounding geometry, formed by the minimum and maximum (X,Y) coordinates:\n\nExamples\n--------\n\n((MINX MINY, MAXX MINY, MAXX MAXY, MINX MAXY, MINX MINY))\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/mbr-minimum-bounding-rectangle/mbr-definition', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/mbr-minimum-bounding-rectangle/mbr-definition');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (768, 34, 'MBRContains', 'Syntax\n------\n\nMBRContains(g1,g2)\n\nDescription\n-----------\n\nReturns 1 or 0 to indicate whether the Minimum Bounding Rectangle of g1 contains the Minimum Bounding Rectangle of g2. This tests the opposite relationship as MBRWithin().\n\nExamples\n--------\n\nSET @g1 = GeomFromText(''Polygon((0 0,0 3,3 3,3 0,0 0))'');\n\nSET @g2 = GeomFromText(''Point(1 1)'');\n\nSELECT MBRContains(@g1,@g2), MBRContains(@g2,@g1);\n+----------------------+----------------------+\n| MBRContains(@g1,@g2) | MBRContains(@g2,@g1) |\n+----------------------+----------------------+\n|                    1 |                    0 |\n+----------------------+----------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/mbr-minimum-bounding-rectangle/mbrcontains', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/mbr-minimum-bounding-rectangle/mbrcontains');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (769, 34, 'MBRCoveredBy', 'Syntax\n------\n\nMBRCoveredBy(g1, g2)\n\nDescription\n-----------\n\nReturns 1 if the minimum bounding rectangle of g1 is covered by the minimum bounding rectangle of g2, otherwise 0.\n\nReturns NULL If any argument is NULL, or an argument is an empty geometry.\n\nExamples\n--------\n\nSET @g1a = ST_GeomFromText(''Point(5 6)'');\nSET @g1b = ST_GeomFromText(''Point(5 11)'');\nSET @g2 = ST_GeomFromText(''Polygon((0 0,0 10,10 10,10 0,0 0))'');\n\nSELECT MBRCoveredby(@g1a,@g2), MBRCoveredby(@g1b,@g2);\n+------------------------+------------------------+\n| MBRCoveredby(@g1a,@g2) | MBRCoveredby(@g1b,@g2) |\n+------------------------+------------------------+\n|                      1 |                      0 |\n+------------------------+------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/mbr-minimum-bounding-rectangle/mbrcoveredby', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/mbr-minimum-bounding-rectangle/mbrcoveredby');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (770, 34, 'MBRDisjoint', 'Syntax\n------\n\nMBRDisjoint(g1,g2)\n\nDescription\n-----------\n\nReturns 1 or 0 to indicate whether the Minimum Bounding Rectangles of the two geometries g1 and g2 are disjoint. Two geometries are disjoint if they do not intersect, that is touch or overlap.\n\nExamples\n--------\n\nSET @g1 = GeomFromText(''Polygon((0 0,0 3,3 3,3 0,0 0))'');\nSET @g2 = GeomFromText(''Polygon((4 4,4 7,7 7,7 4,4 4))'');\nSELECTmbrdisjoint(@g1,@g2);\n+----------------------+\n| mbrdisjoint(@g1,@g2) |\n+----------------------+\n|                    1 |\n+----------------------+\n\nSET @g1 = GeomFromText(''Polygon((0 0,0 3,3 3,3 0,0 0))'');\nSET @g2 = GeomFromText(''Polygon((3 3,3 6,6 6,6 3,3 3))'');\nSELECT mbrdisjoint(@g1,@g2);\n+----------------------+\n| mbrdisjoint(@g1,@g2) |\n+----------------------+\n|                    0 |\n+----------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/mbr-minimum-bounding-rectangle/mbrdisjoint', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/mbr-minimum-bounding-rectangle/mbrdisjoint');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (771, 34, 'MBREqual', 'Syntax\n------\n\nMBREqual(g1,g2)\nMBREquals(g1,g2)\n\nDescription\n-----------\n\nReturns 1 or 0 to indicate whether the Minimum Bounding Rectangles of the two geometries g1 and g2 are the same.\n\nMBREquals is a synonym.\n\nExamples\n--------\n\nSET @g1=GEOMFROMTEXT(''LINESTRING(0 0, 1 2)'');\nSET @g2=GEOMFROMTEXT(''POLYGON((0 0, 0 2, 1 2, 1 0, 0 0))'');\nSELECT MbrEqual(@g1,@g2);\n+-------------------+\n| MbrEqual(@g1,@g2) |\n+-------------------+\n|                 1 |\n+-------------------+\n\nSET @g1=GEOMFROMTEXT(''LINESTRING(0 0, 1 3)'');\nSET @g2=GEOMFROMTEXT(''POLYGON((0 0, 0 2, 1 4, 1 0, 0 0))'');\nSELECT MbrEqual(@g1,@g2);\n+-------------------+\n| MbrEqual(@g1,@g2) |\n+-------------------+\n|                 0 |\n+-------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/mbr-minimum-bounding-rectangle/mbrequal', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/mbr-minimum-bounding-rectangle/mbrequal');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (772, 34, 'MBRIntersects', 'Syntax\n------\n\nMBRIntersects(g1,g2)\n\nDescription\n-----------\n\nReturns 1 or 0 to indicate whether the Minimum Bounding Rectangles of the two geometries g1 and g2 intersect.\n\nExamples\n--------\n\nSET @g1 = GeomFromText(''Polygon((0 0,0 3,3 3,3 0,0 0))'');\nSET @g2 = GeomFromText(''Polygon((3 3,3 6,6 6,6 3,3 3))'');\nSELECT mbrintersects(@g1,@g2);\n+------------------------+\n| mbrintersects(@g1,@g2) |\n+------------------------+\n|                      1 |\n+------------------------+\n\nSET @g1 = GeomFromText(''Polygon((0 0,0 3,3 3,3 0,0 0))'');\nSET @g2 = GeomFromText(''Polygon((4 4,4 7,7 7,7 4,4 4))'');\nSELECT mbrintersects(@g1,@g2);\n+------------------------+\n| mbrintersects(@g1,@g2) |\n+------------------------+\n|                      0 |\n+------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/mbr-minimum-bounding-rectangle/mbrintersects', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/mbr-minimum-bounding-rectangle/mbrintersects');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (773, 34, 'MBROverlaps', 'Syntax\n------\n\nMBROverlaps(g1,g2)\n\nDescription\n-----------\n\nReturns 1 or 0 to indicate whether the Minimum Bounding Rectangles of the two geometries g1 and g2 overlap. The term spatially overlaps is used if two geometries intersect and their intersection results in a geometry of the same dimension but not equal to either of the given geometries.\n\nExamples\n--------\n\nSET @g1 = GeomFromText(''Polygon((0 0,0 3,3 3,3 0,0 0))'');\nSET @g2 = GeomFromText(''Polygon((4 4,4 7,7 7,7 4,4 4))'');\nSELECT mbroverlaps(@g1,@g2);\n+----------------------+\n| mbroverlaps(@g1,@g2) |\n+----------------------+\n|                    0 |\n+----------------------+\n\nSET @g1 = GeomFromText(''Polygon((0 0,0 3,3 3,3 0,0 0))'');\nSET @g2 = GeomFromText(''Polygon((3 3,3 6,6 6,6 3,3 3))'');\nSELECT mbroverlaps(@g1,@g2);\n+----------------------+\n| mbroverlaps(@g1,@g2) |\n+----------------------+\n|                    0 |\n+----------------------+\n\nSET @g1 = GeomFromText(''Polygon((0 0,0 4,4 4,4 0,0 0))'');\nSET @g2 = GeomFromText(''Polygon((3 3,3 6,6 6,6 3,3 3))'');\nSELECT mbroverlaps(@g1,@g2);\n+----------------------+\n| mbroverlaps(@g1,@g2) |\n+----------------------+\n|                    1 |\n+----------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/mbr-minimum-bounding-rectangle/mbroverlaps', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/mbr-minimum-bounding-rectangle/mbroverlaps');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (774, 34, 'MBRTouches', 'Syntax\n------\n\nMBRTouches(g1,g2)\n\nDescription\n-----------\n\nReturns 1 or 0 to indicate whether the Minimum Bounding Rectangles of the two geometries g1 and g2 touch. Two geometries spatially touch if the interiors of the geometries do not intersect, but the boundary of one of the geometries intersects either the boundary or the interior of the other.\n\nExamples\n--------\n\nSET @g1 = GeomFromText(''Polygon((0 0,0 3,3 3,3 0,0 0))'');\nSET @g2 = GeomFromText(''Polygon((4 4,4 7,7 7,7 4,4 4))'');\nSELECT mbrtouches(@g1,@g2);\n+---------------------+\n| mbrtouches(@g1,@g2) |\n+---------------------+\n|                   0 |\n+---------------------+\n\nSET @g1 = GeomFromText(''Polygon((0 0,0 3,3 3,3 0,0 0))'');\nSET @g2 = GeomFromText(''Polygon((3 3,3 6,6 6,6 3,3 3))'');\nSELECT mbrtouches(@g1,@g2);\n+---------------------+\n| mbrtouches(@g1,@g2) |\n+---------------------+\n|                   1 |\n+---------------------+\n\nSET @g1 = GeomFromText(''Polygon((0 0,0 4,4 4,4 0,0 0))'');\nSET @g2 = GeomFromText(''Polygon((3 3,3 6,6 6,6 3,3 3))'');\nSELECT mbrtouches(@g1,@g2);\n+---------------------+\n| mbrtouches(@g1,@g2) |\n+---------------------+\n|                   0 |\n+---------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/mbr-minimum-bounding-rectangle/mbrtouches', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/mbr-minimum-bounding-rectangle/mbrtouches');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (775, 34, 'MBRWithin', 'Syntax\n------\n\nMBRWithin(g1,g2)\n\nDescription\n-----------\n\nReturns 1 or 0 to indicate whether the Minimum Bounding Rectangle of g1 is within the Minimum Bounding Rectangle of g2. This tests the opposite relationship as MBRContains().\n\nExamples\n--------\n\nSET @g1 = GeomFromText(''Polygon((0 0,0 3,3 3,3 0,0 0))'');\nSET @g2 = GeomFromText(''Polygon((0 0,0 5,5 5,5 0,0 0))'');\nSELECT MBRWithin(@g1,@g2), MBRWithin(@g2,@g1);\n+--------------------+--------------------+\n| MBRWithin(@g1,@g2) | MBRWithin(@g2,@g1) |\n+--------------------+--------------------+\n|                  1 |                  0 |\n+--------------------+--------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/mbr-minimum-bounding-rectangle/mbrwithin', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/mbr-minimum-bounding-rectangle/mbrwithin');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (776, 34, 'ST\\_Collect', 'Syntax\n------\n\nST_Collect(g)\n\nDescription\n-----------\n\nST_Collect is an aggregate function that can also be used as a window function.\n\nGiven multiple geometries, returns the aggregation of the distinct geometry arguments. This function also supports the DISTINCT option. If DISTINCT is used, it returns the aggregation of the distinct geometry arguments.\n\nThe resulting value type is chosen using the following policy:\n\n If all arguments are Point values, the result is a MultiPoint value.\n If all arguments are LineString values, the result is a MultiLineString value.\n If all arguments are Polygon values, the result is a MultiPolygon value.\n Otherwise, the result is a GeometryCollection value.\n\nIf there are multiple geometry arguments and those arguments are in the same spatial reference system (SRS), the return value is in that SRS. If those arguments are not in the same SRS, an ER_GIS_DIFFERENT_SRIDS_AGGREGATION error occurs.\n\nExamples\n--------\n\nCREATE OR REPLACE TABLE t1 ( running_number INTEGER NOT NULL\n  AUTO_INCREMENT, grouping_condition INTEGER, location GEOMETRY , PRIMARY KEY (\n  running_number));\n\nINSERT INTO t1 ( grouping_condition, location ) VALUES\n  ( 0,ST_GEOMFROMTEXT(''POINT(0 0)'',4326)),\n  ( 1,ST_GEOMFROMTEXT(''POINT(0 0)'',4326)),\n  ( 0,ST_GEOMFROMTEXT(''POINT(1 0)'',4326)),\n  ( 1,ST_GEOMFROMTEXT(''POINT(2 0)'',4326)),\n  ( 0,ST_GEOMFROMTEXT(''POINT(3 0)'',4326));\n\nSELECT ST_EQUALS( (SELECT ST_COLLECT( location ) AS t FROM t1), \n  ST_GEOMFROMTEXT(''MULTIPOINT(0 0,0 0,1 0,2 0,3 0) '',4326)) AS equals;\n+--------+\n| equals |\n+--------+\n|      1 |\n+--------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/miscellaneous-gis-functions/st_collect', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/miscellaneous-gis-functions/st_collect');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (777, 34, 'ST\\_GeoHash', 'Syntax\n------\n\nST_GeoHash(longitude, latitude, max_length)\nST_GeoHash(point, max_length)\n\nDescription\n-----------\n\nReturns the geohash corresponding to the input values, or NULL if any argument is NULL. Geohashes encode latitude and longitude coordinates into a text string made up only of numeric and lowercase latin letter characters.\n\nThe longitude parameter is a numeric value in the interval \\[180, -180]. latitude is a numeric value in the interval \\[90, -90].\n\nIn the case of point, the x coordinate is treated as the longitude and the y coordinate is treated as the latitude. The same constraints apply.\n\nThe max_length parameter is the upper limit on the resulting string size and cannot exceed 100.\n\nThe ST_LatFromGeoHash function decodes a given geohash and returns the latitude.\n\nExamples\n--------\n\nSELECT ST_GeoHash(ST_GeomFromText(''POINT(1 1)''),15), ST_GeoHash(0,30,15);\n+----------------------------------------------+---------------------+\n| ST_GeoHash(ST_GeomFromText(''POINT(1 1)''),15) | ST_GeoHash(0,30,15) |\n+----------------------------------------------+---------------------+\n| s00twy01mtw037m                              | sj248j248j248j2     |\n+----------------------------------------------+---------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/miscellaneous-gis-functions/st_geohash', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/miscellaneous-gis-functions/st_geohash');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (778, 34, 'ST\\_IsValid', 'Syntax\n------\n\nST_IsValid(g)\n\nDescription\n-----------\n\nGiven a geometry input, returns 1 if the argument is geometrically valid according to the OGC specifications, 0 if the argument is not geometrically valid.\n\nUnlike ST_Validate, requires valid GIS data, or ERROR 3037 (22023): Invalid GIS data provided to function st_isvalid is returned.\n\nExamples\n--------\n\nSELECT ST_IsValid(ST_GeomFromText(''LINESTRING (0 0, 1 1)''));\n+------------------------------------------------------+\n| ST_IsValid(ST_GeomFromText(''LINESTRING (0 0, 1 1)'')) |\n+------------------------------------------------------+\n|                                                    1 |\n+------------------------------------------------------+\n\nSELECT ST_IsValid(ST_GeomFromText(''LINESTRING (0 0, 0 0)''));\n+------------------------------------------------------+\n| ST_IsValid(ST_GeomFromText(''LINESTRING (0 0, 0 0)'')) |\n+------------------------------------------------------+\n|                                                    0 |\n+------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/miscellaneous-gis-functions/st_isvalid', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/miscellaneous-gis-functions/st_isvalid');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (779, 34, 'ST\\_LatFromGeoHash', 'Syntax\n------\n\nST_LatFromGeoHash(geohash)\n\nDescription\n-----------\n\nDecodes a given geohash string and returns the latitude in the interval \\[90, -90].\n\nIf the argument is NULL, the return value is NULL. If the argument is invalid, an ER_INCORRECT_TYPE error is thrown.\n\nThe ST_GeoHash function can be used to generate geohashes.\n\nExamples\n--------\n\nSELECT ST_LatFromGeoHash(''zzzzzzzzz''), ST_LatFromGeoHash(''xvrfxvrfxvrfxvr'');\n+--------------------------------+--------------------------------------+\n| ST_LatFromGeoHash(''zzzzzzzzz'') | ST_LatFromGeoHash(''xvrfxvrfxvrfxvr'') |\n+--------------------------------+--------------------------------------+\n|                             90 |                                   30 |\n+--------------------------------+--------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/miscellaneous-gis-functions/st_latfromgeohash', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/miscellaneous-gis-functions/st_latfromgeohash');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (780, 34, 'ST\\_LongFromGeoHash', 'Syntax\n------\n\nST_LongFromGeoHash(geohash)\n\nDescription\n-----------\n\nDecodes a given geohash string and returns the longitude in the interval \\[180, -180].\n\nIf the argument is NULL, the return value is NULL. If the argument is invalid, an ER_INCORRECT_TYPE error is thrown.\n\nThe ST_GeoHash function can be used to generate geohashes.\n\nExamples\n--------\n\nSELECT ST_LongFromGeoHash(''zzzzzzzzz''), ST_LongFromGeoHash(''sj248j248j248j2'');           \n+---------------------------------+---------------------------------------+\n| ST_LongFromGeoHash(''zzzzzzzzz'') | ST_LongFromGeoHash(''sj248j248j248j2'') |\n+---------------------------------+---------------------------------------+\n|                             180 |                                     0 |\n+---------------------------------+---------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/miscellaneous-gis-functions/st_longfromgeohash', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/miscellaneous-gis-functions/st_longfromgeohash');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (781, 34, 'ST\\_PointFromGeoHash', 'Syntax\n------\n\nST_PointFromGeoHash(geohash, srid)\n\nDescription\n-----------\n\nTakes a given geohash string and returns a point where the x is the longitude and the y is the latitude.\n\nThe latitude is returned as a numeric value in the interval \\[180, -180]. The longitude is returned as a numeric value in the interval \\[90, -90]. If the argument is NULL, the return value is NULL. If the argument is invalid, an ER_GIS_INVALID_DATA is thrown.\n\nExamples\n--------\n\nSELECT ST_ASTEXT(ST_POINTFROMGEOHASH("s00twy01mtw037m",0));\n+-----------------------------------------------------+\n| ST_ASTEXT(ST_POINTFROMGEOHASH("s00twy01mtw037m",0)) |\n+-----------------------------------------------------+\n| POINT(1 1)                                          |\n+-----------------------------------------------------+\n\nSELECT ST_ASTEXT(ST_POINTFROMGEOHASH(ST_GEOHASH(180,90,20),0));\n+---------------------------------------------------------+\n| ST_ASTEXT(ST_POINTFROMGEOHASH(ST_GEOHASH(180,90,20),0)) |\n+---------------------------------------------------------+\n| POINT(180 90)                                           |\n+---------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/miscellaneous-gis-functions/st_pointfromgeohash', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/miscellaneous-gis-functions/st_pointfromgeohash');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (782, 34, 'ST\\_Simplify', 'Syntax\n------\n\nST_Simplify(g, max_distance)\n\nDescription\n-----------\n\nTakes as input a geometry (g) and a double (max_distance). It applies the Ramer–Douglas–Peucker algorithm on g and returns the resulting geometry.\n\nThe goal of the Douglas-Peucker algorithm is to provide generalized simplifications by returning a geometry that is similar to g but uses only a subset of points. To perform the simplification, all the vertices that are shorter than max_distance are removed.\n\nThe algorithm may produce self-intersections and therefore result in invalid geometries. ST_IsValid can be used to test validity of the result.\n\nIf the max_distance is not positive or is NULL, an ER_WRONG_ARGUMENT will occur.\n\nExamples\n--------\n\nSELECT ST_AsText(ST_Simplify(ST_GeomFromText(''LINESTRING(0 0,0 2,2 2,2 4,4 4,4 6,6 6)''), 0.5));\n+-----------------------------------------------------------------------------------------+\n| ST_AsText(ST_Simplify(ST_GeomFromText(''LINESTRING(0 0,0 2,2 2,2 4,4 4,4 6,6 6)''), 0.5)) |\n+-----------------------------------------------------------------------------------------+\n| LINESTRING(0 0,0 2,2 2,2 4,4 4,4 6,6 6)                                                 |\n+-----------------------------------------------------------------------------------------+\n\nSELECT ST_AsText(ST_Simplify(ST_GeomFromText(''LINESTRING(0 0,0 2,2 2,2 4,4 4,4 6,6 6)''), 1));  \n+---------------------------------------------------------------------------------------+\n| ST_AsText(ST_Simplify(ST_GeomFromText(''LINESTRING(0 0,0 2,2 2,2 4,4 4,4 6,6 6)''), 1)) |\n+---------------------------------------------------------------------------------------+\n| LINESTRING(0 0,0 2,2 2,2 4,6 6)                                                       |\n+---------------------------------------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/miscellaneous-gis-functions/st_simplify', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/miscellaneous-gis-functions/st_simplify');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (783, 34, 'ST\\_Validate', 'Syntax\n------\n\nST_Validate(g)\n\nDescription\n-----------\n\nThe function checks that a given geometry is compliant with the Well-Known Binary (WKB) format and Spatial Reference System Identifier (SRID) syntax, and is geometrically valid.\n\nIt returns the geometry if it''s valid, or NULL if not.\n\nThe function is useful to filter out invalid geometry data.\n\nExamples\n--------\n\nSELECT ST_ASTEXT(ST_VALIDATE(ST_GeomFromText(''POINT(1 0)'')));          \n+-------------------------------------------------------+\n| ST_ASTEXT(ST_VALIDATE(ST_GeomFromText(''POINT(1 0)''))) |\n+-------------------------------------------------------+\n| POINT(1 0)                                            |\n+-------------------------------------------------------+\n\nSELECT ST_ASTEXT(ST_VALIDATE(ST_GeomFromText(''POINT(1)'')));  \n+-----------------------------------------------------+\n| ST_ASTEXT(ST_VALIDATE(ST_GeomFromText(''POINT(1)''))) |\n+-----------------------------------------------------+\n| NULL                                                |\n+-----------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/miscellaneous-gis-functions/st_validate', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/miscellaneous-gis-functions/st_validate');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (784, 34, 'X', 'Description\n-----------\n\nA synonym for ST_X.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/point-properties/point-properties-x', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/point-properties/point-properties-x');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (785, 34, 'Y', 'Description\n-----------\n\nA synonym for ST_Y.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/point-properties/point-properties-y', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/point-properties/point-properties-y');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (786, 34, 'ST\\_X', 'Syntax\n------\n\nST_X(p)\nX(p)\n\nDescription\n-----------\n\nReturns the X-coordinate value for the point p as a double-precision number.\n\nST_X() and X() are synonyms.\n\nExamples\n--------\n\nSET @pt = ''Point(56.7 53.34)'';\n\nSELECT X(GeomFromText(@pt));\n+----------------------+\n| X(GeomFromText(@pt)) |\n+----------------------+\n|                 56.7 |\n+----------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/point-properties/st_x', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/point-properties/st_x');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (787, 34, 'ST\\_Y', 'Syntax\n------\n\nST_Y(p)\nY(p)\n\nDescription\n-----------\n\nReturns the Y-coordinate value for the point p as a double-precision number.\n\nST_Y() and Y() are synonyms.\n\nExamples\n--------\n\nSET @pt = ''Point(56.7 53.34)'';\n\nSELECT Y(GeomFromText(@pt));\n+----------------------+\n| Y(GeomFromText(@pt)) |\n+----------------------+\n|                53.34 |\n+----------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/point-properties/st_y', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/point-properties/st_y');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (788, 34, 'CENTROID', 'Description\n-----------\n\nA synonym for ST_CENTROID.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/polygon-properties/centroid', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/polygon-properties/centroid');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (789, 34, 'AREA', 'Description\n-----------\n\nA synonym for ST_AREA.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/polygon-properties/polygon-properties-area', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/polygon-properties/polygon-properties-area');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (790, 34, 'ExteriorRing', 'Description\n-----------\n\nA synonym for ST_ExteriorRing.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/polygon-properties/polygon-properties-exteriorring', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/polygon-properties/polygon-properties-exteriorring');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (791, 34, 'InteriorRingN', 'Description\n-----------\n\nA synonym for ST_InteriorRingN.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/polygon-properties/polygon-properties-interiorringn', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/polygon-properties/polygon-properties-interiorringn');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (792, 34, 'NumInteriorRings', 'Description\n-----------\n\nA synonym for ST_NumInteriorRings.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/polygon-properties/polygon-properties-numinteriorrings', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/polygon-properties/polygon-properties-numinteriorrings');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (793, 34, 'ST\\_AREA', 'Syntax\n------\n\nST_Area(poly)\nArea(poly)\n\nDescription\n-----------\n\nReturns as a double-precision number the area of the Polygon value poly, as measured in its spatial reference system.\n\nST_Area() and Area() are synonyms.\n\nExamples\n--------\n\nSET @poly = ''Polygon((0 0,0 3,3 0,0 0),(1 1,1 2,2 1,1 1))'';\n\nSELECT Area(GeomFromText(@poly));\n+---------------------------+\n| Area(GeomFromText(@poly)) |\n+---------------------------+\n|                         4 |\n+---------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/polygon-properties/st_area', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/polygon-properties/st_area');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (794, 34, 'ST\\_CENTROID', 'Syntax\n------\n\nST_Centroid(mpoly)\nCentroid(mpoly)\n\nDescription\n-----------\n\nReturns a point reflecting the mathematical centroid (geometric center) for the MultiPolygon _mpoly_. The resulting point will not necessarily be on the MultiPolygon.\n\nST_Centroid() and Centroid() are synonyms.\n\nExamples\n--------\n\nSET @poly = ST_GeomFromText(''POLYGON((0 0,20 0,20 20,0 20,0 0))'');\nSELECT ST_AsText(ST_Centroid(@poly)) AS center;\n+--------------+\n| center       |\n+--------------+\n| POINT(10 10) |\n+--------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/polygon-properties/st_centroid', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/polygon-properties/st_centroid');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (795, 34, 'ST\\_ExteriorRing', 'Syntax\n------\n\nST_ExteriorRing(poly)\nExteriorRing(poly)\n\nDescription\n-----------\n\nReturns the exterior ring of the Polygon value poly as a LineString.\n\nST_ExteriorRing() and ExteriorRing() are synonyms.\n\nExamples\n--------\n\nSET @poly = ''Polygon((0 0,0 3,3 3,3 0,0 0),(1 1,1 2,2 2,2 1,1 1))'';\n\nSELECT AsText(ExteriorRing(GeomFromText(@poly)));\n+-------------------------------------------+\n| AsText(ExteriorRing(GeomFromText(@poly))) |\n+-------------------------------------------+\n| LINESTRING(0 0,0 3,3 3,3 0,0 0)           |\n+-------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/polygon-properties/st_exteriorring', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/polygon-properties/st_exteriorring');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (796, 34, 'ST\\_InteriorRingN', 'Syntax\n------\n\nST_InteriorRingN(poly,N)\nInteriorRingN(poly,N)\n\nDescription\n-----------\n\nReturns the N-th interior ring for the Polygon value poly as a LineString. Rings are numbered beginning with 1.\n\nST_InteriorRingN() and InteriorRingN() are synonyms.\n\nExamples\n--------\n\nSET @poly = ''Polygon((0 0,0 3,3 3,3 0,0 0),(1 1,1 2,2 2,2 1,1 1))'';\n\nSELECT AsText(InteriorRingN(GeomFromText(@poly),1));\n+----------------------------------------------+\n| AsText(InteriorRingN(GeomFromText(@poly),1)) |\n+----------------------------------------------+\n| LINESTRING(1 1,1 2,2 2,2 1,1 1)              |\n+----------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/polygon-properties/st_interiorringn', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/polygon-properties/st_interiorringn');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (797, 34, 'ST\\_NumInteriorRings', 'Syntax\n------\n\nST_NumInteriorRings(poly)\nNumInteriorRings(poly)\n\nDescription\n-----------\n\nReturns an integer containing the number of interior rings in the Polygon value poly.\n\nNote that according the OpenGIS standard, a POLYGON should have exactly one ExteriorRing and all other rings should lie within that ExteriorRing and thus be the InteriorRings. Practically, however, some systems, including MariaDB''s, permit polygons to have several ''ExteriorRings''. In the case of there being multiple, non-overlapping exterior rings ST_NumInteriorRings() will return 1.\n\nST_NumInteriorRings() and NumInteriorRings() are synonyms.\n\nExamples\n--------\n\nSET @poly = ''Polygon((0 0,0 3,3 3,3 0,0 0),(1 1,1 2,2 2,2 1,1 1))'';\n\nSELECT NumInteriorRings(GeomFromText(@poly));\n+---------------------------------------+\n| NumInteriorRings(GeomFromText(@poly)) |\n+---------------------------------------+\n|                                     1 |\n+---------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/polygon-properties/st_numinteriorrings', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/polygon-properties/st_numinteriorrings');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (798, 34, 'AsWKB', 'Description\n-----------\n\nA synonym for ST_AsBinary().\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/aswkb', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/aswkb');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (799, 34, 'GeometryCollectionFromWKB', 'Description\n-----------\n\nA synonym for ST_GeomCollFromWKB.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/geometrycollectionfromwkb', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/geometrycollectionfromwkb');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (800, 34, 'GeometryFromWKB', 'Description\n-----------\n\nA synonym for ST_GeomFromWKB.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/geometryfromwkb', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/geometryfromwkb');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (801, 34, 'LineStringFromWKB', 'Description\n-----------\n\nA synonym for ST_LineFromWKB.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/linestringfromwkb', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/linestringfromwkb');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (802, 34, 'MLineFromWKB', 'Syntax\n------\n\nMLineFromWKB(wkb[,srid])\nMultiLineStringFromWKB(wkb[,srid])\n\nDescription\n-----------\n\nConstructs a MULTILINESTRING value using its WKB representation and SRID.\n\nMLineFromWKB() and MultiLineStringFromWKB() are synonyms.\n\nExamples\n--------\n\nSET @g = ST_AsBinary(MLineFromText(''MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))''));\n\nSELECT ST_AsText(MLineFromWKB(@g));\n+--------------------------------------------------------+\n| ST_AsText(MLineFromWKB(@g))                            |\n+--------------------------------------------------------+\n| MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48)) |\n+--------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/mlinefromwkb', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/mlinefromwkb');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (803, 34, 'MPointFromWKB', 'Syntax\n------\n\nMPointFromWKB(wkb[,srid])\nMultiPointFromWKB(wkb[,srid])\n\nDescription\n-----------\n\nConstructs a MULTIPOINT value using its WKB representation and SRID.\n\nMPointFromWKB() and MultiPointFromWKB() are synonyms.\n\nExamples\n--------\n\nSET @g = ST_AsBinary(MPointFromText(''MultiPoint( 1 1, 2 2, 5 3, 7 2, 9 3, 8 4, 6 6, 6 9, 4 9, 1 5 )''));\n\nSELECT ST_AsText(MPointFromWKB(@g));\n+-----------------------------------------------------+\n| ST_AsText(MPointFromWKB(@g))                        |\n+-----------------------------------------------------+\n| MULTIPOINT(1 1,2 2,5 3,7 2,9 3,8 4,6 6,6 9,4 9,1 5) |\n+-----------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/mpointfromwkb', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/mpointfromwkb');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (804, 34, 'MPolyFromWKB', 'Syntax\n------\n\nMPolyFromWKB(wkb[,srid])\nMultiPolygonFromWKB(wkb[,srid])\n\nDescription\n-----------\n\nConstructs a MULTIPOLYGON value using its WKB representation and SRID.\n\nMPolyFromWKB() and MultiPolygonFromWKB() are synonyms.\n\nExamples\n--------\n\nSET @g = ST_AsBinary(MPointFromText(''MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))''));\n\nSELECT ST_AsText(MPolyFromWKB(@g))\\G\n************************ 1. row ************************\nST_AsText(MPolyFromWKB(@g)): MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/mpolyfromwkb', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/mpolyfromwkb');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (805, 34, 'MultiLineStringFromWKB', 'Description\n-----------\n\nA synonym for MLineFromWKB().\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/multilinestringfromwkb', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/multilinestringfromwkb');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (806, 34, 'MultiPointFromWKB', 'Description\n-----------\n\nA synonym for MPointFromWKB.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/multipointfromwkb', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/multipointfromwkb');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (807, 34, 'MultiPolygonFromWKB', 'Description\n-----------\n\nSynonym for MPolyFromWKB.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/multipolygonfromwkb', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/multipolygonfromwkb');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (808, 34, 'PolygonFromWKB', 'Description\n-----------\n\nA synonym for ST_PolyFromWKB.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/polygonfromwkb', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/polygonfromwkb');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (809, 34, 'ST\\_AsBinary', 'Syntax\n------\n\nST_AsBinary(g)\nAsBinary(g)\nST_AsWKB(g)\nAsWKB(g)\n\nDescription\n-----------\n\nConverts a value in internal geometry format to its WKB representation and returns the binary result.\n\nST_AsBinary(), AsBinary(), ST_AsWKB() and AsWKB() are synonyms,\n\nExamples\n--------\n\nSET @poly = ST_GeomFromText(''POLYGON((0 0,0 1,1 1,1 0,0 0))'');\nSELECT ST_AsBinary(@poly);\n\nSELECT ST_AsText(ST_GeomFromWKB(ST_AsWKB(@poly)));\n+--------------------------------------------+\n| ST_AsText(ST_GeomFromWKB(ST_AsWKB(@poly))) |\n+--------------------------------------------+\n| POLYGON((0 0,0 1,1 1,1 0,0 0))             |\n+--------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/st_asbinary', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/st_asbinary');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (810, 34, 'ST\\_AsWKB', 'Description\n-----------\n\nA synonym for ST_AsBinary().\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/st_aswkb', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/st_aswkb');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (811, 34, 'ST\\_GeomCollFromWKB', 'Syntax\n------\n\nST_GeomCollFromWKB(wkb[,srid])\nST_GeometryCollectionFromWKB(wkb[,srid])\nGeomCollFromWKB(wkb[,srid])\nGeometryCollectionFromWKB(wkb[,srid])\n\nDescription\n-----------\n\nConstructs a GEOMETRYCOLLECTION value using its WKB representation and SRID.\n\nST_GeomCollFromWKB(), ST_GeometryCollectionFromWKB(), GeomCollFromWKB() and GeometryCollectionFromWKB() are synonyms.\n\nExamples\n--------\n\nSET @g = ST_AsBinary(ST_GeomFromText(''GEOMETRYCOLLECTION(\n   POLYGON((5 5,10 5,10 10,5 5)),POINT(10 10))''));\n\nSELECT ST_AsText(ST_GeomCollFromWKB(@g));\n+----------------------------------------------------------------+\n| ST_AsText(ST_GeomCollFromWKB(@g))                              |\n+----------------------------------------------------------------+\n| GEOMETRYCOLLECTION(POLYGON((5 5,10 5,10 10,5 5)),POINT(10 10)) |\n+----------------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/st_geomcollfromwkb', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/st_geomcollfromwkb');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (812, 34, 'ST\\_GeometryCollectionFromWKB', 'Description\n-----------\n\nA synonym for ST_GeomCollFromWKB.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/st_geometrycollectionfromwkb', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/st_geometrycollectionfromwkb');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (813, 34, 'ST\\_GeometryFromWKB', 'Description\n-----------\n\nA synonym for ST_GeomFromWKB.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/st_geometryfromwkb', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/st_geometryfromwkb');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (814, 34, 'ST\\_GeomFromWKB', 'Syntax\n------\n\nST_GeomFromWKB(wkb[,srid])\nST_GeometryFromWKB(wkb[,srid])\nGeomFromWKB(wkb[,srid])\nGeometryFromWKB(wkb[,srid])\n\nDescription\n-----------\n\nConstructs a geometry value of any type using its WKB representation and SRID.\n\nST_GeomFromWKB(), ST_GeometryFromWKB(), GeomFromWKB() and GeometryFromWKB() are synonyms.\n\nExamples\n--------\n\nSET @g = ST_AsBinary(ST_LineFromText(''LINESTRING(0 4, 4 6)''));\n\nSELECT ST_AsText(ST_GeomFromWKB(@g));\n+-------------------------------+\n| ST_AsText(ST_GeomFromWKB(@g)) |\n+-------------------------------+\n| LINESTRING(0 4,4 6)           |\n+-------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/st_geomfromwkb', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/st_geomfromwkb');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (815, 34, 'ST\\_LineFromWKB', 'Syntax\n------\n\nST_LineFromWKB(wkb[,srid])\nLineFromWKB(wkb[,srid])\nST_LineStringFromWKB(wkb[,srid])\nLineStringFromWKB(wkb[,srid])\n\nDescription\n-----------\n\nConstructs a LINESTRING value using its WKB representation and SRID.\n\nST_LineFromWKB(), LineFromWKB(), ST_LineStringFromWKB(), and LineStringFromWKB() are synonyms.\n\nExamples\n--------\n\nSET @g = ST_AsBinary(ST_LineFromText(''LineString(0 4,4 6)''));\n\nSELECT ST_AsText(ST_LineFromWKB(@g)) AS l;\n+---------------------+\n| l                   |\n+---------------------+\n| LINESTRING(0 4,4 6) |\n+---------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/st_linefromwkb', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/st_linefromwkb');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (816, 34, 'ST\\_LineStringFromWKB', 'Description\n-----------\n\nA synonym for ST_LineFromWKB.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/st_linestringfromwkb', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/st_linestringfromwkb');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (817, 34, 'ST\\_MPointFromWKB', 'Description\n-----------\n\nA synonym for ST_GeomFromWKB.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/st_mpointfromwkb', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/st_mpointfromwkb');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (818, 34, 'ST\\_MPolyFromWKB', 'Description\n-----------\n\nA synonym for ST_GeomFromWKB.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/st_mpolyfromwkb', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/st_mpolyfromwkb');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (819, 34, 'ST\\_MultiPointFromWKB', 'Description\n-----------\n\nA synonym for ST_GeomFromWKB.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/st_multipointfromwkb', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/st_multipointfromwkb');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (820, 34, 'ST\\_MultiPolygonFromWKB', 'Description\n-----------\n\nA synonym for ST_GeomFromWKB.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/st_multipolygonfromwkb', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/st_multipolygonfromwkb');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (821, 34, 'ST\\_PointFromWKB', 'Syntax\n------\n\nST_PointFromWKB(wkb[,srid])\nPointFromWKB(wkb[,srid])\n\nDescription\n-----------\n\nConstructs a POINT value using its WKB representation and SRID.\n\nST_PointFromWKB() and PointFromWKB() are synonyms.\n\nExamples\n--------\n\nSET @g = ST_AsBinary(ST_PointFromText(''POINT(0 4)''));\n\nSELECT ST_AsText(ST_PointFromWKB(@g)) AS p;\n+------------+\n| p          |\n+------------+\n| POINT(0 4) |\n+------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/st_pointfromwkb', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/st_pointfromwkb');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (822, 34, 'ST\\_PolyFromWKB', 'Syntax\n------\n\nST_PolyFromWKB(wkb[,srid])\nST_PolygonFromWKB(wkb[,srid])\nPolyFromWKB(wkb[,srid])\nPolygonFromWKB(wkb[,srid])\n\nDescription\n-----------\n\nConstructs a POLYGON value using its WKB representation and SRID.\n\nST_PolyFromWKB(), ST_PolygonFromWKB(), PolyFromWKB() and PolygonFromWKB() are synonyms.\n\nExamples\n--------\n\nSET @g = ST_AsBinary(ST_PolyFromText(''POLYGON((1 1,1 5,4 9,6 9,9 3,7 2,1 1))''));\n\nSELECT ST_AsText(ST_PolyFromWKB(@g)) AS p;\n+----------------------------------------+\n| p                                      |\n+----------------------------------------+\n| POLYGON((1 1,1 5,4 9,6 9,9 3,7 2,1 1)) |\n+----------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/st_polyfromwkb', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/st_polyfromwkb');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (823, 34, 'ST\\_PolygonFromWKB', 'Description\n-----------\n\nA synonym for ST_PolyFromWKB.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/st_polygonfromwkb', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/st_polygonfromwkb');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (824, 34, 'Well-Known Binary (WKB) Format', 'Description\n-----------\n\nWKB stands for Well-Known Binary, a format for representing geographical and geometrical data.\n\nWKB uses 1-byte unsigned integers, 4-byte unsigned integers, and 8-byte double-precision numbers.\n\n The first byte indicates the byte order. 00 for big endian, or 01 for little endian.\n The next 4 bytes indicate the geometry type. Values from 1 to 7 indicate whether the type is Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, or GeometryCollection respectively.\n The 8-byte floats represent the co-ordinates.\n\nTake the following example, a sequence of 21 bytes each represented by two hex digits:\n\n``\n000000000140000000000000004010000000000000\n``\n\n It''s big endian\n   000000000140000000000000004010000000000000\n It''s a POINT\n   000000000140000000000000004010000000000000\n The X co-ordinate is 2.0\n   000000000140000000000000004010000000000000\n The Y-co-ordinate is 4.0\n  * 000000000140000000000000004010000000000000\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/well-known-binary-wkb-format', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/well-known-binary-wkb-format');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (825, 34, 'AsBinary', 'Description\n-----------\n\nA synonym for ST_AsBinary().\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/wkb-asbinary', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/wkb-asbinary');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (826, 34, 'GeomCollFromWKB', 'Description\n-----------\n\nA synonym for ST_GeomCollFromWKB.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/wkb-geomcollfromwkb', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/wkb-geomcollfromwkb');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (827, 34, 'GeomFromWKB', 'Description\n-----------\n\nA synonym for ST_GeomFromWKB.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/wkb-geomfromwkb', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/wkb-geomfromwkb');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (828, 34, 'LineFromWKB', 'Description\n-----------\n\nA synonym for ST_LineFromWKB.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/wkb-linefromwkb', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/wkb-linefromwkb');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (829, 34, 'PointFromWKB', 'Description\n-----------\n\nA synonym for ST_PointFromWKB.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/wkb-pointfromwkb', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/wkb-pointfromwkb');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (830, 34, 'PolyFromWKB', 'Description\n-----------\n\nA synonym for ST_PolyFromWKB.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/wkb-polyfromwkb', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkb/wkb-polyfromwkb');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (831, 34, 'GeometryCollectionFromText', 'Description\n-----------\n\nA synonym for ST_GeomCollFromText.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/geometrycollectionfromtext', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/geometrycollectionfromtext');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (832, 34, 'GeometryFromText', 'Description\n-----------\n\nA synonym for ST_GeomFromText.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/geometryfromtext', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/geometryfromtext');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (833, 34, 'LineStringFromText', 'Description\n-----------\n\nA synonym for ST_LineFromText.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/linestringfromtext', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/linestringfromtext');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (834, 34, 'MLineFromText', 'Syntax\n------\n\nMLineFromText(wkt[,srid])\nMultiLineStringFromText(wkt[,srid])\n\nDescription\n-----------\n\nConstructs a MULTILINESTRING value using its WKT representation and SRID.\n\nMLineFromText() and MultiLineStringFromText() are synonyms.\n\nExamples\n--------\n\nCREATE TABLE gis_multi_line (g MULTILINESTRING);\nSHOW FIELDS FROM gis_multi_line;\nINSERT INTO gis_multi_line VALUES\n    (MultiLineStringFromText(''MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))'')),\n    (MLineFromText(''MULTILINESTRING((10 48,10 21,10 0))'')),\n    (MLineFromWKB(AsWKB(MultiLineString(\n      LineString(Point(1, 2), Point(3, 5)), \n      LineString(Point(2, 5), Point(5, 8), Point(21, 7))))));\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/mlinefromtext', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/mlinefromtext');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (835, 34, 'MPointFromText', 'Syntax\n------\n\nMPointFromText(wkt[,srid])\nMultiPointFromText(wkt[,srid])\n\nDescription\n-----------\n\nConstructs a MULTIPOINT value using its WKT representation and SRID.\n\nMPointFromText() and MultiPointFromText() are synonyms.\n\nExamples\n--------\n\nCREATE TABLE gis_multi_point (g MULTIPOINT);\nSHOW FIELDS FROM gis_multi_point;\nINSERT INTO gis_multi_point VALUES\n    (MultiPointFromText(''MULTIPOINT(0 0,10 10,10 20,20 20)'')),\n    (MPointFromText(''MULTIPOINT(1 1,11 11,11 21,21 21)'')),\n    (MPointFromWKB(AsWKB(MultiPoint(Point(3, 6), Point(4, 10)))));\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/mpointfromtext', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/mpointfromtext');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (836, 34, 'MPolyFromText', 'Syntax\n------\n\nMPolyFromText(wkt[,srid])\nMultiPolygonFromText(wkt[,srid])\n\nDescription\n-----------\n\nConstructs a MULTIPOLYGON value using its WKT representation and SRID.\n\nMPolyFromText() and MultiPolygonFromText() are synonyms.\n\nExamples\n--------\n\nCREATE TABLE gis_multi_polygon  (g MULTIPOLYGON);\nSHOW FIELDS FROM gis_multi_polygon;\nINSERT INTO gis_multi_polygon VALUES\n    (MultiPolygonFromText(''MULTIPOLYGON(\n       ((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),\n       ((59 18,67 18,67 13,59 13,59 18)))'')),\n    (MPolyFromText(''MULTIPOLYGON(\n       ((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),\n       ((59 18,67 18,67 13,59 13,59 18)))'')),\n    (MPolyFromWKB(AsWKB(MultiPolygon(Polygon(\n       LineString(Point(0, 3), Point(3, 3), Point(3, 0), Point(0, 3)))))));\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/mpolyfromtext', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/mpolyfromtext');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (837, 34, 'MultiLineStringFromText', 'Description\n-----------\n\nA synonym for MLineFromText.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/multilinestringfromtext', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/multilinestringfromtext');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (838, 34, 'MultiPointFromText', 'Description\n-----------\n\nA synonym for MPointFromText.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/multipointfromtext', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/multipointfromtext');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (839, 34, 'MultiPolygonFromText', 'Description\n-----------\n\nA synonym for MPolyFromText.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/multipolygonfromtext', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/multipolygonfromtext');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (840, 34, 'PolygonFromText', 'Description\n-----------\n\nA synonym for ST_PolyFromText.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/polygonfromtext', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/polygonfromtext');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (841, 34, 'ST\\_AsText', 'Syntax\n------\n\nST_AsText(g)\nAsText(g)\nST_AsWKT(g)\nAsWKT(g)\n\nDescription\n-----------\n\nConverts a value in internal geometry format to its WKT representation and returns the string result.\n\nST_AsText(), AsText(), ST_AsWKT() and AsWKT() are all synonyms.\n\nExamples\n--------\n\nSET @g = ''LineString(1 1,4 4,6 6)'';\n\nSELECT ST_AsText(ST_GeomFromText(@g));\n+--------------------------------+\n| ST_AsText(ST_GeomFromText(@g)) |\n+--------------------------------+\n| LINESTRING(1 1,4 4,6 6)        |\n+--------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/st_astext', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/st_astext');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (842, 34, 'ST\\_ASWKT', 'Description\n-----------\n\nA synonym for ST_ASTEXT().\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/st_aswkt', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/st_aswkt');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (843, 34, 'ST\\_GeomCollFromText', 'Syntax\n------\n\nST_GeomCollFromText(wkt[,srid])\nST_GeometryCollectionFromText(wkt[,srid])\nGeomCollFromText(wkt[,srid])\nGeometryCollectionFromText(wkt[,srid])\n\nDescription\n-----------\n\nConstructs a GEOMETRYCOLLECTION value using its WKT representation and SRID.\n\nST_GeomCollFromText(), ST_GeometryCollectionFromText(), GeomCollFromText() and GeometryCollectionFromText() are all synonyms.\n\nExamples\n--------\n\nCREATE TABLE gis_geometrycollection  (g GEOMETRYCOLLECTION);\nSHOW FIELDS FROM gis_geometrycollection;\nINSERT INTO gis_geometrycollection VALUES\n    (GeomCollFromText(''GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))'')),\n    (GeometryFromWKB(AsWKB(GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9)))))),\n    (GeomFromText(''GeometryCollection()'')),\n    (GeomFromText(''GeometryCollection EMPTY''));\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/st_geomcollfromtext', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/st_geomcollfromtext');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (844, 34, 'ST\\_GeometryCollectionFromText', 'Description\n-----------\n\nA synonym for ST_GeomCollFromText.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/st_geometrycollectionfromtext', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/st_geometrycollectionfromtext');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (845, 34, 'ST\\_GeometryFromText', 'Description\n-----------\n\nA synonym for ST_GeomFromText.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/st_geometryfromtext', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/st_geometryfromtext');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (846, 34, 'ST\\_GeomFromText', 'Syntax\n------\n\nST_GeomFromText(wkt[,srid])\nST_GeometryFromText(wkt[,srid])\nGeomFromText(wkt[,srid])\nGeometryFromText(wkt[,srid])\n\nST_MultiLineStringFromText(wkt[,srid])\nST_MLineFromText(wkt[,srid])\nST_MPointFromText(wkt[,srid])\nST_MultiPointFromText(wkt[,srid])\n\nDescription\n-----------\n\nConstructs a geometry value of any type using its WKT representation and SRID.\n\nGeomFromText(), GeometryFromText(), ST_GeomFromText(), ST_GeometryFromText(), ST_MultiLineStringFromText, ST_MLineFromText, ST_MultiPolyFromText and ST_MPolygonFromText are all synonyms.\n\nExamples\n--------\n\nSET @g = ST_GEOMFROMTEXT(''POLYGON((1 1,1 5,4 9,6 9,9 3,7 2,1 1))'');\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/st_geomfromtext', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/st_geomfromtext');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (847, 34, 'ST\\_LineFromText', 'Syntax\n------\n\nST_LineFromText(wkt[,srid])\nST_LineStringFromText(wkt[,srid])\nLineFromText(wkt[,srid])\nLineStringFromText(wkt[,srid])\n\nDescription\n-----------\n\nConstructs a LINESTRING value using its WKT representation and SRID.\n\nST_LineFromText(), ST_LineStringFromText(), ST_LineFromText() and ST_LineStringFromText() are all synonyms.\n\nExamples\n--------\n\nCREATE TABLE gis_line  (g LINESTRING);\nSHOW FIELDS FROM gis_line;\nINSERT INTO gis_line VALUES\n    (LineFromText(''LINESTRING(0 0,0 10,10 0)'')),\n    (LineStringFromText(''LINESTRING(10 10,20 10,20 20,10 20,10 10)'')),\n    (LineStringFromWKB(AsWKB(LineString(Point(10, 10), Point(40, 10)))));\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/st_linefromtext', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/st_linefromtext');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (848, 34, 'ST\\_LineStringFromText', 'Description\n-----------\n\nA synonym for ST_LineFromText.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/st_linestringfromtext', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/st_linestringfromtext');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (849, 34, 'ST\\_MPointFromText', 'Description\n-----------\n\nA synonym for ST_GeomFromText.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/st_mpointfromtext', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/st_mpointfromtext');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (850, 34, 'ST\\_MPolyFromText', 'Description\n-----------\n\nA synonym for ST_GeomFromText.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/st_mpolyfromtext', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/st_mpolyfromtext');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (851, 34, 'ST\\_MultiLineStringFromText', 'Description\n-----------\n\nA synonym for ST_GeomFromText.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/st_multilinestringfromtext', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/st_multilinestringfromtext');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (852, 34, 'ST\\_MultiPointFromText', 'Description\n-----------\n\nA synonym for ST_GeomFromText.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/st_multipointfromtext', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/st_multipointfromtext');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (853, 34, 'ST\\_MultiPolygonFromText', 'Description\n-----------\n\nA synonym for ST_GeomFromText.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/st_multipolygonfromtext', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/st_multipolygonfromtext');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (854, 34, 'ST\\_PointFromText', 'Syntax\n------\n\nST_PointFromText(wkt[,srid])\nPointFromText(wkt[,srid])\n\nDescription\n-----------\n\nConstructs a POINT value using its WKT representation and SRID.\n\nST_PointFromText() and PointFromText() are synonyms.\n\nExamples\n--------\n\nCREATE TABLE gis_point  (g POINT);\nSHOW FIELDS FROM gis_point;\nINSERT INTO gis_point VALUES\n    (PointFromText(''POINT(10 10)'')),\n    (PointFromText(''POINT(20 10)'')),\n    (PointFromText(''POINT(20 20)'')),\n    (PointFromWKB(AsWKB(PointFromText(''POINT(10 20)''))));\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/st_pointfromtext', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/st_pointfromtext');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (855, 34, 'ST\\_PolyFromText', 'Syntax\n------\n\nST_PolyFromText(wkt[,srid])\nST_PolygonFromText(wkt[,srid])\nPolyFromText(wkt[,srid])\nPolygonFromText(wkt[,srid])\n\nDescription\n-----------\n\nConstructs a POLYGON value using its WKT representation and SRID.\n\nST_PolyFromText(), ST_PolygonFromText(), PolyFromText() and ST_PolygonFromText() are all synonyms.\n\nExamples\n--------\n\nCREATE TABLE gis_polygon   (g POLYGON);\nINSERT INTO gis_polygon VALUES\n    (PolygonFromText(''POLYGON((10 10,20 10,20 20,10 20,10 10))'')),\n    (PolyFromText(''POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))''));\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/st_polyfromtext', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/st_polyfromtext');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (856, 34, 'ST\\_PolygonFromText', 'Description\n-----------\n\nA synonym for ST_PolyFromText.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/st_polygonfromtext', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/st_polygonfromtext');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (857, 34, 'AsText', 'Description\n-----------\n\nA synonym for ST_AsText().\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/wkt-astext', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/wkt-astext');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (858, 34, 'AsWKT', 'Description\n-----------\n\nA synonym for ST_AsText().\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/wkt-aswkt', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/wkt-aswkt');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (859, 34, 'WKT Definition', 'Description\n-----------\n\nThe Well-Known Text (WKT) representation of Geometry is designed to exchange geometry data in ASCII form. Examples of the basic geometry types include:\n\n| Geometry Types                                                       |\n| -------------------------------------------------------------------- |\n| POINT                           |\n| LINESTRING                 |\n| POLYGON                       |\n| MULTIPOINT                 |\n| MULTILINESTRING       |\n| MULTIPOLYGON             |\n| GEOMETRYCOLLECTION |\n| GEOMETRY        |\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/wkt-definition', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/wkt-definition');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (860, 34, 'GeomCollFromText', 'Description\n-----------\n\nA synonym for ST_GeomCollFromText.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/wkt-geomcollfromtext', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/wkt-geomcollfromtext');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (861, 34, 'GeomFromText', 'Description\n-----------\n\nA synonym for ST_GeomFromText.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/wkt-geomfromtext', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/wkt-geomfromtext');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (862, 34, 'LineFromText', 'Description\n-----------\n\nA synonym for ST_LineFromText.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/wkt-linefromtext', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/wkt-linefromtext');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (863, 34, 'PointFromText', 'Description\n-----------\n\nA synonym for ST_PointFromText.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/wkt-pointfromtext', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/wkt-pointfromtext');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (864, 34, 'PolyFromText', 'Description\n-----------\n\nA synonym for ST_PolyFromText.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/wkt-polyfromtext', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/wkt-polyfromtext');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (865, 34, 'ST\\_MLineFromText', 'Description\n-----------\n\nA synonym for ST_GeomFromText.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/wkt-st_mlinefromtext', '', 'https://mariadb.com/docs/server/reference/sql-statements/geometry-constructors/wkt/wkt-st_mlinefromtext');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (866, 35, 'DEALLOCATE / DROP PREPARE', 'Syntax\n------\n\n{DEALLOCATE | DROP} PREPARE stmt_name\n\nDescription\n-----------\n\nTo deallocate a prepared statement produced with PREPARE, use aDEALLOCATE PREPARE statement that refers to the prepared statement name.\n\nA prepared statement is implicitly deallocated when a new PREPARE command is issued. In that case, there is no need to use DEALLOCATE.\n\nAttempting to execute a prepared statement after deallocating it results in an error, as if it was not prepared at all:\n\n``sql\nERROR 1243 (HY000): Unknown prepared statement handler (stmt_name) given to EXECUTE\n`\n\nIf the specified statement has not been PREPAREd, an error similar to the following will be produced:\n\n`sql\nERROR 1243 (HY000): Unknown prepared statement handler (stmt_name) given to DEALLOCATE PREPARE\n``\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/prepared-statements/deallocate-drop-prepare', '', 'https://mariadb.com/docs/server/reference/sql-statements/prepared-statements/deallocate-drop-prepare');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (867, 35, 'EXECUTE IMMEDIATE', 'Syntax\n------\n\nEXECUTE IMMEDIATE statement\n    [USING param[, param] ...]\n\nparam:\n    expression | IGNORE | DEFAULT\n\nDescription\n-----------\n\nEXECUTE IMMEDIATE executes a dynamic SQL statement created on the fly, which can reduce performance overhead. For example:\n\n``sql\nEXECUTE IMMEDIATE ''SELECT 1''\n`\n\nwhich is shorthand for:\n\n`sql\nPREPARE stmt FROM "select 1";\nEXECUTE stmt;\nDEALLOCATE PREPARE stmt;\n`\n\nEXECUTE IMMEDIATE supports complex expressions as prepare source and parameters:\n\n`sql\nEXECUTE IMMEDIATE CONCAT(''SELECT COUNT() FROM '', ''t1'', '' WHERE a=?'') USING 5+5;\n`\n\nLimitations: subselects and stored function calls are not supported as a prepare source.\n\nThe following examples return an error:\n\n`sql\nCREATE OR REPLACE FUNCTION f1() RETURNS VARCHAR(64) RETURN ''SELECT  FROM t1'';\nEXECUTE IMMEDIATE f1();\nERROR 1970 (42000): EXECUTE IMMEDIATE does not support subqueries or stored functions\n\nEXECUTE IMMEDIATE (SELECT ''SELECT  FROM t1'');\nERROR 1064 (42000): You have an error in your SQL syntax; check the manual that \n  corresponds to your MariaDB server version for the right syntax to use near \n  ''SELECT ''SELECT  FROM t1'')'' at line 1\n\nCREATE OR REPLACE FUNCTION f1() RETURNS INT RETURN 10;\nEXECUTE IMMEDIATE ''SELECT  FROM t1 WHERE a=?'' USING f1();\nERROR 1970 (42000): EXECUTE..USING does not support subqueries or stored functions\n\nEXECUTE IMMEDIATE ''SELECT  FROM t1 WHERE a=?'' USING (SELECT 10);\nERROR 1064 (42000): You have an error in your SQL syntax; check the manual that \n  corresponds to your MariaDB server version for the right syntax to use near \n  ''SELECT 10)'' at line 1\n`\n\nOne can use a user or an SP variable as a workaround:\n\n`sql\nCREATE OR REPLACE FUNCTION f1() RETURNS VARCHAR(64) RETURN ''SELECT  FROM t1'';\nSET @stmt=f1();\nEXECUTE IMMEDIATE @stmt;\n\nSET @stmt=(SELECT ''SELECT 1'');\nEXECUTE IMMEDIATE @stmt;\n\nCREATE OR REPLACE FUNCTION f1() RETURNS INT RETURN 10;\nSET @param=f1();\nEXECUTE IMMEDIATE ''SELECT  FROM t1 WHERE a=?'' USING @param;\n\nSET @param=(SELECT 10);\nEXECUTE IMMEDIATE ''SELECT  FROM t1 WHERE a=?'' USING @param;\n`\n\nEXECUTE IMMEDIATE supports user variables and SP variables as OUT parameters:\n\n`sql\nDELIMITER $$\nCREATE OR REPLACE PROCEDURE p1(OUT a INT)\nBEGIN\n  SET a:= 10;\nEND;\n$$\nDELIMITER ;\nSET @a=2;\nEXECUTE IMMEDIATE ''CALL p1(?)'' USING @a;\nSELECT @a;\n+------+\n| @a   |\n+------+\n|   10 |\n+------+\n`\n\nSimilar to PREPARE, EXECUTE IMMEDIATE is allowed in stored procedures but is not allowed in stored functions.\n\nThis example uses EXECUTE IMMEDIATE inside a stored procedure:\n\n`sql\nDELIMITER $$\nCREATE OR REPLACE PROCEDURE p1()\nBEGIN\n  EXECUTE IMMEDIATE ''SELECT 1'';\nEND;\n$$\nDELIMITER ;\nCALL p1;\n+---+\n| 1 |\n+---+\n| 1 |\n+---+\n`\n\nThis script returns an error:\n\n`sql\nDELIMITER $$\nCREATE FUNCTION f1() RETURNS INT\nBEGIN\n  EXECUTE IMMEDIATE ''DO 1'';\n  RETURN 1;\nEND;\n$$\nERROR 1336 (0A000): Dynamic SQL is not allowed in stored function or trigger\n`\n\nEXECUTE IMMEDIATE can use DEFAULT and IGNORE indicators as bind parameters:\n\n`sql\nCREATE OR REPLACE TABLE t1 (a INT DEFAULT 10);\nEXECUTE IMMEDIATE ''INSERT INTO t1 VALUES (?)'' USING DEFAULT;\nSELECT  FROM t1;\n+------+\n| a    |\n+------+\n|   10 |\n+------+\n`\n\nEXECUTE IMMEDIATE increments the Com_execute_immediate status variable, as well as the Com_stmt_prepare, Com_stmt_execute and Com_stmt_close status variables.\n\nNote, EXECUTE IMMEDIATE does not increment the Com_execute_sql status variable. _Com_execute_sql_ is used only for PREPARE..EXECUTE.\n\nThis session screenshot demonstrates how EXECUTE IMMEDIATE affects status variables:\n\n`sql\nSELECT  FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME RLIKE \n  (''COM_(EXECUTE|STMT_PREPARE|STMT_EXECUTE|STMT_CLOSE)'');\n\n+-----------------------+----------------+\n| VARIABLE_NAME         | VARIABLE_VALUE |\n+-----------------------+----------------+\n| COM_EXECUTE_IMMEDIATE | 0              |\n| COM_EXECUTE_SQL       | 0              |\n| COM_STMT_CLOSE        | 0              |\n| COM_STMT_EXECUTE      | 0              |\n| COM_STMT_PREPARE      | 0              |\n+-----------------------+----------------+\n\nEXECUTE IMMEDIATE ''SELECT 1'';\n+---+\n| 1 |\n+---+\n| 1 |\n+---+\n\nSELECT  FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME RLIKE \n  (''COM_(EXECUTE|STMT_PREPARE|STMT_EXECUTE|STMT_CLOSE)'');\n+-----------------------+----------------+\n| VARIABLE_NAME         | VARIABLE_VALUE |\n+-----------------------+----------------+\n| COM_EXECUTE_IMMEDIATE | 1              |\n| COM_EXECUTE_SQL       | 0              |\n| COM_STMT_CLOSE        | 1              |\n| COM_STMT_EXECUTE      | 1              |\n| COM_STMT_PREPARE      | 1              |\n+-----------------------+----------------+\n``\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/prepared-statements/execute-immediate', '', 'https://mariadb.com/docs/server/reference/sql-statements/prepared-statements/execute-immediate');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (868, 35, 'EXECUTE Statement', 'Syntax\n------\n\nEXECUTE stmt_name\n    [USING expression[, expression] ...]\n\nDescription\n-----------\n\nAfter preparing a statement with PREPARE, you execute it with anEXECUTE statement that refers to the prepared statement name. If the prepared statement contains any parameter markers, you must supply aUSING clause that lists expressions containing the values to be bound to the parameters. The USING clause must name exactly as many expressions as the number of parameter markers in the statement.\n\nYou can execute a given prepared statement multiple times, passing different variables to it or setting the variables to different values before each execution.\n\nIf the specified statement has not been PREPAREd, an error similar to the following is produced:\n\n``sql\nERROR 1243 (HY000): Unknown prepared statement handler (stmt_name) given to EXECUTE\n`\n\nEXECUTE` with arbitrary expression as parameters can be used, not just user variables (@var_name).\n\nYou can only use user variables (@var_name) as parameters.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/prepared-statements/execute-statement', '', 'https://mariadb.com/docs/server/reference/sql-statements/prepared-statements/execute-statement');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (869, 35, 'PREPARE Statement', 'Syntax\n------\n\nPREPARE stmt_name FROM preparable_stmt\n\nDescription\n-----------\n\nThe PREPARE statement prepares a statement and assigns it a name,stmt_name, by which to refer to the statement later. Statement names are not case sensitive. preparable_stmt is an expression with the text of the statement. It cannot contain stored function calls or subqueries. The text must represent a single SQL statement, not multiple statements. Within the statement, ? characters can be used as parameter markers to indicate where data values are to be bound to the query later when you execute it. The ? characters should not be enclosed within quotes, even if you intend to bind them to string values. Parameter markers can be used only where expressions should appear, not for SQL keywords, identifiers, and so forth.\n\nThe scope of a prepared statement is the session within which it is created. Other sessions cannot see it.\n\nIf a prepared statement with the given name already exists, it is deallocated implicitly before the new statement is prepared. This means that if the new statement contains an error and cannot be prepared, an error is returned and no statement with the given name exists.\n\nPrepared statements can be PREPARE and EXECUTE in a stored procedure, but not in a stored function or trigger. Also, even if the statement is prepared with PREPARE in a procedure, it will not be deallocated when the procedure execution ends.\n\nA prepared statement can access user-defined variables, but not local variables or procedure''s parameters.\n\nIf the prepared statement contains a syntax error, PREPARE will fail. As a side effect, stored procedures can use it to check if a statement is valid. For example:\n\n``sql\nCREATE PROCEDURE test_stmt(IN sql_text TEXT)\nBEGIN\n        DECLARE EXIT HANDLER FOR SQLEXCEPTION\n        BEGIN\n                SELECT CONCAT(sql_text, '' is not valid'');\n        END;\n        SET @SQL := sql_text;\n        PREPARE stmt FROM @SQL;\n        DEALLOCATE PREPARE stmt;\nEND;\n`\n\nThe FOUND_ROWS() and ROW_COUNT() functions, if called immediately after EXECUTE, return the number of rows read or affected by the prepared statements; however, if they are called after DEALLOCATE PREPARE, they provide information about this statement. If the prepared statement produces errors or warnings, GET DIAGNOSTICS return information about them. DEALLOCATE PREPARE shouldn''t clear the diagnostics area, unless it produces an error.\n\nA prepared statement is executed with EXECUTE and released with DEALLOCATE PREPARE.\n\nThe max_prepared_stmt_count server system variable determines the number of allowed prepared statements that can be prepared on the server. If it is set to 0, prepared statements are not allowed. If the limit is reached, an error similar to the following will be produced:\n\n`sql\nERROR 1461 (42000): Can''t create more than max_prepared_stmt_count statements \n  (current value: 0)\n`\n\nOracle Mode\n\nIn Oracle mode, PREPARE stmt FROM ''SELECT :1, :2'' is used instead of ?.\n\nPermitted Statements\n\nThe following is valid from MariaDB 10.6.2.\n\nAll statements can be prepared, except PREPARE, EXECUTE, and DEALLOCATE / DROP PREPARE.\n\nPrior to this, not all statements can be prepared. Only the following SQL commands are permitted:\n\n ALTER TABLE\n ANALYZE TABLE\n BINLOG\n CACHE INDEX\n CALL\n CHANGE MASTER\n CHECKSUM {TABLE | TABLES}\n COMMIT\n {CREATE | DROP} DATABASE\n {CREATE | DROP} INDEX\n {CREATE | RENAME | DROP} TABLE\n {CREATE | RENAME | DROP} USER\n {CREATE | DROP} VIEW\n DELETE\n DESCRIBE\n DO\n EXPLAIN\n FLUSH {TABLE | TABLES | TABLES WITH READ LOCK | HOSTS | PRIVILEGES | LOGS | STATUS |\\\n  MASTER | SLAVE | DES_KEY_FILE | USER_RESOURCES | QUERY CACHE | TABLE_STATISTICS |\\\n  INDEX_STATISTICS | USER_STATISTICS | CLIENT_STATISTICS}\n GRANT\n INSERT\n INSTALL {PLUGIN | SONAME}\n HANDLER READ\n KILL\n LOAD INDEX INTO CACHE\n OPTIMIZE TABLE\n REPAIR TABLE\n REPLACE\n RESET {MASTER | SLAVE | QUERY CACHE}\n REVOKE\n ROLLBACK\n SELECT\n SET\n SET GLOBAL SQL_SLAVE_SKIP_COUNTER\n SET ROLE\n SET SQL_LOG_BIN\n SET TRANSACTION ISOLATION LEVEL\n SHOW EXPLAIN\n SHOW {DATABASES | TABLES | OPEN TABLES | TABLE STATUS | COLUMNS | INDEX | TRIGGERS |EVENTS | GRANTS | CHARACTER SET | COLLATION | ENGINES | \\PLUGINS [SONAME] | PRIVILEGES |PROCESSLIST | PROFILE | PROFILES | VARIABLES | STATUS | WARNINGS | ERRORS |TABLE_STATISTICS | INDEX_STATISTICS | USER_STATISTICS | CLIENT_STATISTICS | AUTHORS |CONTRIBUTORS}\n SHOW CREATE {DATABASE | TABLE | VIEW | PROCEDURE | FUNCTION | TRIGGER | EVENT}\n SHOW {FUNCTION | PROCEDURE} CODE\n SHOW BINLOG EVENTS\n SHOW SLAVE HOSTS\n SHOW {MASTER | BINARY} LOGS\n SHOW {MASTER | SLAVE | TABLES | INNODB | FUNCTION | PROCEDURE} STATUS\n SLAVE {START | STOP}\n TRUNCATE TABLE\n SHUTDOWN\n UNINSTALL {PLUGIN | SONAME}\n UPDATE\n\nSynonyms are not listed here, but can be used. For example, DESC can be used instead of DESCRIBE.\n\nCompound statements can be prepared too.\n\nNote that if a statement can be run in a stored routine, it will work even if it is called by a prepared statement. For example, SIGNAL can''t be directly prepared. However, it is allowed in stored routines. If the x() procedure contains SIGNAL, you can still prepare and execute the ''CALL x();'' prepared statement.\n\nPREPARE supports most kinds of expressions as well, for example:\n\n`sql\nPREPARE stmt FROM CONCAT(''SELECT  FROM '', table_name);\n`\n\nWhen PREPARE is used with a statement which is not supported, the following error is produced:\n\n`sql\nERROR 1295 (HY000): This command is not supported in the prepared statement protocol yet\n``\n\nExamples\n--------\n\nCREATE TABLE t1 (a INT,b CHAR(10));\nINSERT INTO t1 VALUES (1,"one"),(2, "two"),(3,"three");\nPREPARE test FROM "select * from t1 where a=?";\nSET @param=2;\nEXECUTE test USING @param;\n+------+------+\n| a    | b    |\n+------+------+\n|    2 | two  |\n+------+------+\nSET @param=3;\nEXECUTE test USING @param;\n+------+-------+\n| a    | b     |\n+------+-------+\n|    3 | three |\n+------+-------+\nDEALLOCATE PREPARE test;\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/prepared-statements/prepare-statement', '', 'https://mariadb.com/docs/server/reference/sql-statements/prepared-statements/prepare-statement');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (870, 35, 'BEGIN END', 'Syntax\n------\n\n[begin_label:] BEGIN [NOT ATOMIC]\n    [statement_list]\nEND [end_label]\n\nDescription\n-----------\n\nBEGIN ... END syntax is used for writing compound statements. A compound statement can contain multiple statements, enclosed by the BEGIN and END keywords. statement_list represents a list of one or more statements, each terminated by a semicolon (i.e., ;) statement delimiter. statement_list is\\\noptional, which means that the empty compound statement (BEGIN END) is legal.\n\nNote that END will perform a commit. If you are running in autocommit mode, every statement will be committed separately. If you are not running in autocommit mode, you must execute a COMMIT or ROLLBACK after END to get the database up to date.\n\nUse of multiple statements requires that a client is able to send statement strings containing the statement delimiter. This is handled in the mysql command-line client with the DELIMITER command.\\\nChanging the ; end-of-statement delimiter (for example, to//) allows ; to be used in a program body.\n\nA compound statement within a stored program can be labeled. end_label cannot be given unless begin_label also is present. If both are present, they must be the same.\n\nBEGIN ... END constructs can be nested. Each block can define its own variables, a CONDITION, a HANDLER and a CURSOR, which don''t exist in the outer blocks. The most local declarations override the outer objects which use the same name (see example below).\n\nThe declarations order is the following:\n\n DECLARE local variables\n DECLARE CONDITIONs\n DECLARE CURSORs\n DECLARE HANDLERs\n\nNote that DECLARE HANDLER contains another BEGIN ... END construct.\n\nHere is an example of a very simple, anonymous block:\n\n``sql\nBEGIN NOT ATOMIC\nSET @a=1;\nCREATE TABLE test.t1(a INT);\nEND|\n`\n\nBelow is an example of nested blocks in a stored procedure:\n\n`sql\nCREATE PROCEDURE t( )\nBEGIN\n   DECLARE x TINYINT UNSIGNED DEFAULT 1;\n   BEGIN\n      DECLARE x CHAR(2) DEFAULT ''02'';\n       DECLARE y TINYINT UNSIGNED DEFAULT 10;\n       SELECT x, y;\n   END;\n   SELECT x;\nEND;\n`\n\nIn this example, a TINYINT variable, x is declared in the outter block. But in the inner block x is re-declared as a CHAR and an y variable is declared. The inner SELECT shows the "new" value of x, and the value of y. But when x is selected in the outer block, the "old" value is returned. The final SELECT doesn''t try to read y`, because it doesn''t exist in that context.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/begin-end', '', 'https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/begin-end');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (871, 35, 'CASE Statement', 'Syntax\n------\n\nCASE case_value\n    WHEN when_value THEN statement_list\n    [WHEN when_value THEN statement_list] ...\n    [ELSE statement_list]\nEND CASE\n\nDescription\n-----------\n\nThe text on this page describes the CASE statement for stored programs. See the CASE OPERATOR for details on the CASE operator outside of stored programs.\n\nThe CASE statement for stored programs implements a complex conditional construct. If a search_condition evaluates to true, the corresponding SQL statement list is executed. If no search condition matches, the statement list in the ELSE clause is executed. Each statement_list consists of one or more statements.\n\nThe CASE statement cannot have an ELSE NULL clause, and it is terminated with END CASE instead of END. implements a complex conditional construct. If a search_condition evaluates to true, the corresponding SQL statement list is executed. If no search condition matches, the statement list in the ELSE clause is executed. Each statement_list consists of one or more statements.\n\nIf no when_value or search_condition matches the value tested and the CASE statement contains no ELSE clause, a Case not found for CASE statement error results.\n\nEach statement_list consists of one or more statements; an empty statement_list is not allowed. To handle situations where no value is matched by any WHEN clause, use an ELSE containing an empty BEGIN ... END block, as shown in this example:\n\n``sql\nDELIMITER |\nCREATE PROCEDURE p()\nBEGIN\n  DECLARE v INT DEFAULT 1;\n  CASE v\n    WHEN 2 THEN SELECT v;\n    WHEN 3 THEN SELECT 0;\n    ELSE BEGIN END;\n  END CASE;\nEND;\n|\n`\n\nThe indentation used here in the ELSE clause is for purposes of clarity only and is not otherwise significant. See Delimiters in the mariadb client for more on the use of the delimiter command.\n\nNote: The syntax of the CASE statement used inside stored programs differs slightly from that of the SQL CASE expression described in CASE OPERATOR. The CASE statement cannot have an ELSE NULL clause, and it is terminated with END CASE instead of END`.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/case-statement', '', 'https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/case-statement');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (872, 35, 'DECLARE CONDITION', 'Syntax\n------\n\nDECLARE condition_name CONDITION FOR condition_value\n\ncondition_value:\n    SQLSTATE [VALUE] sqlstate_value\n  | mysql_error_code\n\nDescription\n-----------\n\nThe DECLARE ... CONDITION statement defines a named error condition. It specifies a condition that needs specific handling and associates a name with that condition. Later, the name can be used in a DECLARE ... HANDLER, SIGNAL or RESIGNAL statement (as long as the statement is located in the same BEGIN ... END block).\n\nConditions must be declared after local variables, but before CURSORs and HANDLERs.\n\nA condition_value for DECLARE ... CONDITION can be an SQLSTATE value (a 5-character string literal) or a MySQL error code (a number). You should not use SQLSTATE value ''00000'' or MySQL error code 0, because those indicate success rather than an error condition. If you try, or if you specify an invalid SQLSTATE value, an error like this is produced:\n\n``sql\nERROR 1407 (42000): Bad SQLSTATE: ''00000''\n`\n\nFor a list of SQLSTATE` values and MariaDB error codes, see MariaDB Error Codes.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/declare-condition', '', 'https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/declare-condition');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (873, 35, 'DECLARE HANDLER', 'Syntax\n------\n\nDECLARE handler_type HANDLER\n    FOR condition_value [, condition_value] ...\n    statement\n\nhandler_type:\n    CONTINUE\n  | EXIT \n  | UNDO\n\ncondition_value:\n    SQLSTATE [VALUE] sqlstate_value\n  | condition_name\n  | SQLWARNING\n  | NOT FOUND\n  | SQLEXCEPTION\n  | mariadb_error_code\n\nDescription\n-----------\n\nThe DECLARE ... HANDLER statement specifies handlers that each may deal with one or more conditions. If one of these conditions occurs, the specified statement is executed. statement can be a simple statement (for example, SET var_name = value), or it can be a compound statement written using BEGIN and END.\n\nHandlers must be declared after local variables, a CONDITION and a CURSOR.\n\nFor a CONTINUE handler, execution of the current program continues after execution of the handler statement. For an EXIT handler, execution terminates for the BEGIN ... END compound statement in which the handler is declared. (This is true even if the condition occurs in an inner block.) The UNDO handler type statement is not supported.\n\nIf a condition occurs for which no handler has been declared, the default action is EXIT.\n\nA condition_value for DECLARE ... HANDLER can be any of the following values:\n\n An SQLSTATE value (a 5-character string literal) or a MariaDB error code (a number). You should not use SQLSTATE value ''00000'' or MariaDB error code 0, because those indicate success rather than an error condition. For a list of SQLSTATE values and MariaDB error codes, see MariaDB Error Codes.\n A condition name previously specified with DECLARE ... CONDITION. It must be in the same stored program. See DECLARE CONDITION.\n SQLWARNING is shorthand for the class of SQLSTATE values that begin with ''01''.\n NOT FOUND is shorthand for the class of SQLSTATE values that begin with ''02''. This is relevant only the context of cursors and is used to control what happens when a cursor reaches the end of a data set. If no more rows are available, a No Data condition occurs with SQLSTATE value 02000. To detect this condition, you can set up a handler for it (or for a NOT FOUND condition). An example is shown in Cursor Overview. This condition also occurs for SELECT ... INTO var_list statements that retrieve no rows.\n SQLEXCEPTION is shorthand for the class of SQLSTATE values that do not begin with ''00'', ''01'', or ''02''.\n\nWhen an error raises, in some cases it could be handled by multiple HANDLERs. For example, there may be an handler for 1050 error, a separate handler for the 42S01 SQLSTATE, and another separate handler for the SQLEXCEPTION class: in theory all occurrences of HANDLER may catch the 1050 error, but MariaDB chooses the HANDLER with the highest precedence. Here are the precedence rules:\n\n Handlers which refer to an error code have the highest precedence.\n Handlers which refer to a SQLSTATE come next.\n Handlers which refer to an error class have the lowest precedence.\n\nIn some cases, a statement could produce multiple errors. If this happens, in some cases multiple handlers could have the highest precedence. In such cases, the choice of the handler is indeterminate.\n\nNote that if an error occurs within a CONTINUE HANDLER block, it can be handled by another HANDLER. However, a HANDLER which is already in the stack (that is, it has been called to handle an error and its execution didn''t finish yet) cannot handle new errors—this prevents endless loops. For example, suppose that a stored procedure contains a CONTINUE HANDLER for SQLWARNING and another CONTINUE HANDLER for NOT FOUND. At some point, a NOT FOUND error occurs, and the execution enters the NOT FOUND HANDLER. But within that handler, a warning occurs, and the execution enters the SQLWARNING HANDLER. If another NOT FOUND error occurs, it cannot be handled again by the NOT FOUND HANDLER, because its execution is not finished.\n\nWhen a DECLARE HANDLER block can handle more than one error condition, it may be useful to know which errors occurred. To do so, you can use the GET DIAGNOSTICS statement.\n\nAn error that is handled by a DECLARE HANDLER construct can be issued again using the RESIGNAL statement.\n\nBelow is an example using DECLARE HANDLER:\n\n``sql\nCREATE TABLE test.t (s1 INT, PRIMARY KEY (s1));\n\nDELIMITER //\n\nCREATE PROCEDURE handlerdemo ( )\n     BEGIN\n       DECLARE CONTINUE HANDLER FOR SQLSTATE ''23000'' SET @x2 = 1;\n       SET @x = 1;\n       INSERT INTO test.t VALUES (1);\n       SET @x = 2;\n       INSERT INTO test.t VALUES (1);\n       SET @x = 3;\n     END;\n     //\n\nDELIMITER ;\n\nCALL handlerdemo( );\n\nSELECT @x;\n+------+\n| @x   |\n+------+\n|    3 |\n+------+\n``\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/declare-handler', '', 'https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/declare-handler');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (874, 35, 'DECLARE TYPE', 'Description\n-----------\n\nThe DECLARE TYPE declaration specifies user-defined data types that must be compatible with Oracle within stored procedures and anonymous blocks. It provides Oracle-compatible type declarations, such as record types, associative arrays, and REF CURSOR types, which allows for more flexible data handling and better compatibility with Oracle PL/SQL.\n\nAssociative arrays (INDEX BY tables) offer an in-memory key-value structure for quick data storage and effective lookups. REF CURSOR types allow for the creation of cursor variables that refer to query result sets and can be passed between program blocks.\n\nThe general syntax for defining associative array types is as follows:\n\n``sql\nDECLARE\n   TYPE type_name TABLE OF rec_type_name INDEX BY idx_type_name\n`\n\n type_name supports explicit and anchored data types (for instance, t1.col1%TYPE).\n rec_type_name supports scalar and record data types.\n The INDEX BY clause defines the key type using idx_type_name, which supports integer and string data types.\n\nAssociative Arrays\n\nIn Oracle, associative arrays (called index-by tables) are sparse collections of elements indexed by keys, which can be integers or strings.\n\nHere’s an example of how to declare an associative array in Oracle:\n\n`sql\nDECLARE\n  TYPE array_t IS TABLE OF VARCHAR2(64) INDEX BY PLS_INTEGER;\n  array array_t;\nBEGIN\n  array(1) := ''Hello'';\n  array(2) := ''World'';\n  DBMS_OUTPUT.PUT_LINE(array(1));\nEND;\n`\n\nMethods\n\nAssociative arrays support the following methods:\n\n FIRST — a function that returns the first key\n LAST — a function that returns the last key\n NEXT — a function that returns the key after the given one\n PRIOR — a function that returns the key before the given one\n COUNT — a function that returns the number of elements\n EXISTS — a function that returns TRUE if the key exists\n DELETE — a procedure that removes a specific key, or clears the array\n\nWhile the MariaDB implementation is largely aligned with Oracle’s implementation, there are a few differences:\n\n Only literals as keys in the constructor: When using constructors, keys must be literals — Oracle allows expressions.\n Collation control: Instead of NLS_SORT or NLS_COMP, MariaDB uses the SQL-standard COLLATE` clause.\n* No nested associative arrays: Arrays of arrays are not supported.\n\nThese differences are largely rooted in architectural constraints — MariaDB is aiming at staying as close to Oracle semantics as possible while maintaining performance and predictability.\n\nExamples\n--------\n\nDECLARE\n  TYPE salary IS TABLE OF NUMBER INDEX BY VARCHAR2(20);\n  salary_list salary;\n  name VARCHAR2(20);\nBEGIN\n  salary_list(''Rajnisj'') := 62000;\n  salary_list(''James'') := 78000;\n  name:= salary_list.FIRST;\n  WHILE name IS NOT NULL\n  LOOP\n    dbms_output.put_line(name || '' '' || TO_CHAR(salary_list(name)));\n    name:= salary_list.NEXT(name);\n  END LOOP;\nEND;\n/\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/declare-type', '', 'https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/declare-type');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (875, 35, 'DECLARE Variable', 'Syntax\n------\n\nDECLARE var_name [, var_name] ... [[ROW] TYPE OF]] type [DEFAULT value]\n\nDescription\n-----------\n\nThis statement is used to declare local variables within stored programs. To provide a default value for the variable, include a DEFAULT clause. The value can be specified as an expression (even subqueries are permitted); it need not be a constant. If theDEFAULT clause is missing, the initial value is NULL.\n\nLocal variables are treated like stored routine parameters with respect to data type and overflow checking. See CREATE PROCEDURE.\n\nLocal variables must be declared before CONDITIONs, CURSORs and HANDLERs.\n\nLocal variable names are not case sensitive.\n\nThe scope of a local variable is within the BEGIN ... END block where it is declared. The variable can be referred to in blocks nested within the declaring block, except those blocks that declare a variable with the same name.\n\nTYPE OF / ROW TYPE OF\n\nAnchored data types allow a data type to be defined based on another object, such as a table row, rather than specifically set in the declaration. If the anchor object changes, so will the anchored data type. This can lead to routines being easier to maintain, so that if the data type in the table is changed, it will automatically be changed in the routine as well.\n\nVariables declared with ROW TYPE OF will have the same features as implicit ROW variables. It is not possible to use ROW TYPE OF variables in a LIMIT clause.\n\nThe real data type of TYPE OF and ROW TYPE OF table_name will become known at the very beginning of the stored routine call. ALTER TABLE or DROP TABLE statements performed inside the current routine on the tables that appear in anchors won''t affect the data type of the anchored variables, even if the variable is declared after an ALTER TABLE or DROP TABLE statement.\n\nThe real data type of a ROW TYPE OF cursor_name variable will become known when execution enters into the block where the variable is declared. Data type instantiation will happen only once. In a cursor ROW TYPE OF variable that is declared inside a loop, its data type will become known on the very first iteration and won''t change on further loop iterations.\n\nThe tables referenced in TYPE OF and ROW TYPE OF declarations will be checked for existence at the beginning of the stored routine call. CREATE PROCEDURE or CREATE FUNCTION will not check the referenced tables for existence.\n\nDynamic Cursors Limitation&#x20;\n\nROW TYPE OF is not supported for dynamic cursors (cursors declared for a prepared statement). This is because the cursor''s structure is dependent on the prepared statement, which is not known at the time the stored procedure context is created.\n\nExamples\n--------\n\nDECLARE name VARCHAR(5) DEFAULT ''monty'';\n  DECLARE x INT DEFAULT 10;\n  DECLARE Y SMALLINT;\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/declare-variable', '', 'https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/declare-variable');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (876, 35, 'FOR', 'Syntax\n------\n\n[begin_label:]\nFOR var_name IN [ REVERSE ] lower_bound .. upper_bound\nDO statement_list\nEND FOR [ end_label ]\n\nDescription\n-----------\n\nFOR loops allow code to be executed a fixed number of times.\n\nIn an integer range FOR loop, MariaDB will compare the lower bound and upper bound values, and assign the lower bound value to a counter. If REVERSE is not specified, and the upper bound value is greater than or equal to the counter, the counter will be incremented and the statement will continue, after which the loop is entered again. If the upper bound value is greater than the counter, the loop will be exited.\n\nDynamic Cursors Limitation\n\nFOR loops cannot be used with dynamic cursors (cursors declared for prepared statement names). To handle dynamic cursors, employ explicit OPEN, FETCH, and CLOSE statements inside a LOOP or similar construct.\n\nIf REVERSE is specified, the counter is decremented, and the upper bound value needs to be less than or equal for the loop to continue.\n\nExamples\n--------\n\nCREATE TABLE t1 (a INT);\n\nDELIMITER //\n\nFOR i IN 1..3\nDO\n  INSERT INTO t1 VALUES (i);\nEND FOR;\n//\n\nDELIMITER ;\n\nSELECT * FROM t1;\n+------+\n| a    |\n+------+\n|    1 |\n|    2 |\n|    3 |\n+------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/for', '', 'https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/for');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (877, 35, 'GOTO', 'Syntax\n------\n\nGOTO label\n\nDescription\n-----------\n\nThe GOTO statement causes the code to jump to the specified label, and continue operating from there. It is only accepted when in Oracle mode.\n\nExamples\n--------\n\nSET sql_mode=ORACLE;\n\nDELIMITER //\n\nCREATE OR REPLACE PROCEDURE p1 AS\n\nBEGIN\n\n  SELECT 1;\n  GOTO label;\n  SELECT 2;\n  <<label>>\n  SELECT 3;\n\nEND;\n\n//\n\nDELIMITER \n\nCALL p1();\n+---+\n| 1 |\n+---+\n| 1 |\n+---+\n1 row in set (0.000 sec)\n\n+---+\n| 3 |\n+---+\n| 3 |\n+---+\n1 row in set (0.000 sec)\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/goto', '', 'https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/goto');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (878, 35, 'IF', 'Syntax\n------\n\nIF search_condition THEN statement_list\n    [ELSEIF search_condition THEN statement_list] ...\n    [ELSE statement_list]\nEND IF;\n\nDescription\n-----------\n\nIF implements a basic conditional construct. If the search_condition evaluates to true, the corresponding SQL statement list is executed. If no search_condition matches, the statement list in the ELSE clause is executed. Each statement_list consists of one or more statements.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/if', '', 'https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/if');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (879, 35, 'ITERATE', 'Description\n-----------\n\nSyntax\n\n``sql\nITERATE label\n`\n\nITERATE can appear only within LOOP, REPEAT, and WHILE statements.ITERATE means "do the loop again", and uses the statement''s label to determine which statements to repeat. The label must be in the same stored program, not in a caller procedure.\n\nIf you try to use ITERATE with a non-existing label, or if the label is associated to a construct which is not a loop, the following error will be produced:\n\n`sql\nERROR 1308 (42000): ITERATE with no matching label: <label_name>\n`\n\nBelow is an example of how ITERATE might be used:\n\n`sql\nCREATE PROCEDURE doiterate(p1 INT)\nBEGIN\n  label1: LOOP\n    SET p1 = p1 + 1;\n    IF p1 < 10 THEN ITERATE label1; END IF;\n    LEAVE label1;\n  END LOOP label1;\n  SET @x = p1;\nEND\n``\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/iterate', '', 'https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/iterate');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (880, 35, 'Labels', 'Description\n-----------\n\nSyntax\n\n``sql\nlabel: <construct>\n[label]\n`\n\nLabels are MariaDB identifiers which can be used to identify a BEGIN ... END construct or a loop. They have a maximum length of 16 characters and can be quoted with backticks (i.e.., \\\\\\).\n\nLabels have a start part and an end part. The start part must precede the portion of code it refers to, must be followed by a colon (:) and can be on the same or different line. The end part is optional and adds nothing, but can make the code more readable. If used, the end part must precede the construct''s delimiter (;). Constructs identified by a label can be nested. Each construct can be identified by only one label.\n\nLabels need not be unique in the stored program they belong to. However, a label for an inner loop cannot be identical to a label for an outer loop. In this case, the following error would be produced:\n\n``sql\nERROR 1309 (42000): Redefining label <label_name>\n`\n\nLEAVE and ITERATE statements can be used to exit or repeat a portion of code identified by a label. They must be in the same Stored Routine, Trigger or Event which contains the target label.\n\nBelow is an example using a simple label that is used to exit a LOOP:\n\n`sql\nCREATE PROCEDURE test_sp()\nBEGIN\n   my_label:\n   LOOP\n      SELECT ''looping'';\n      LEAVE my_label;\n   END LOOP;\n   SELECT ''out of loop'';\nEND;\n`\n\nThe following label is used to exit a procedure, and has an end part:\n\n`sql\nCREATE PROCEDURE test_sp()\nmy_label:\nBEGIN\n   IF @var = 1 THEN\n      LEAVE my_label;\n   END IF;\n   DO something();\nEND my_label;\n``\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/labels', '', 'https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/labels');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (881, 35, 'LEAVE', 'Description\n-----------\n\nSyntax\n\n``sql\nLEAVE label\n`\n\nThis statement is used to exit the flow control construct that has the given label. The label must be in the same stored program, not in a caller procedure. LEAVE can be used within BEGIN ... END or loop constructs (LOOP, REPEAT, WHILE). In Stored Procedures, Triggers and Events, LEAVE can refer to the outmost BEGIN ... END construct; in that case, the program exits the procedure. In Stored Functions, RETURN can be used instead.\n\nLEAVE cannot be used to exit a DECLARE HANDLER block.\n\nIf you try to LEAVE a non-existing label, or if you try to LEAVE a HANDLER block, the following error will be produced:\n\n`sql\nERROR 1308 (42000): LEAVE with no matching label: <label_name>\n`\n\nThe following example uses LEAVE to exit the procedure if a condition is true:\n\n`sql\nCREATE PROCEDURE proc(IN p TINYINT)\nCONTAINS SQL\nwhole_proc:\nBEGIN\n   SELECT 1;\n   IF p < 1 THEN\n      LEAVE whole_proc;\n   END IF;\n   SELECT 2;\nEND;\n\nCALL proc(0);\n+---+\n| 1 |\n+---+\n| 1 |\n+---+\n``\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/leave', '', 'https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/leave');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (882, 35, 'LOOP', 'Syntax\n------\n\n[begin_label:] LOOP\n    statement_list\nEND LOOP [end_label]\n\nDescription\n-----------\n\nLOOP implements a simple loop construct, enabling repeated execution of the statement list, which consists of one or more statements, each terminated by a semicolon (i.e., ;) statement delimiter. The statements within the loop are repeated until the loop is exited; usually this is accomplished with a LEAVE statement.\n\nA LOOP statement can be labeled. end_label cannot be given unlessbegin_label also is present. If both are present, they must be the same.\n\nSee Delimiters in the mariadb client for more on delimiter usage in the client.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/loop', '', 'https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/loop');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (883, 35, 'CLOSE', 'Syntax\n------\n\nCLOSE cursor_name\n\nDescription\n-----------\n\nThis statement closes a previously opened cursor. The cursor must have been previously opened or else an error occurs.\n\nIf not closed explicitly, a cursor is closed at the end of the compound statement in which it was declared.\n\nSee Cursor Overview for an example.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/programmatic-compound-statements-cursors/close', '', 'https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/programmatic-compound-statements-cursors/close');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (884, 35, 'Cursor Overview', 'Description\n-----------\n\nA cursor is a structure that allows you to go over records sequentially, and perform processing based on the result.\n\nMariaDB permits cursors inside stored programs, and MariaDB cursors are non-scrollable, read-only and case-insensitive.\n\n Non-scrollable means that the rows can only be fetched in the order specified by the SELECT statement. Rows cannot be skipped, you cannot jump to a specific row, and you cannot fetch rows in reverse order.\n Read-only means that data cannot be updated through the cursor.\n Assensitive means that the cursor points to the actual underlying data. This kind of cursor is quicker than the alternative, an insensitive cursor, as no data is copied to a temporary table. However, changes to the data being used by the cursor will affect the cursor data.\n\nCursors are created with a DECLARE CURSOR statement and opened with an OPEN statement. Rows are read with a FETCH statement before the cursor is finally closed with a CLOSE statement.\n\nWhen FETCH is issued and there are no more rows to extract, the following error is produced:\n\n``sql\nERROR 1329 (02000): No data - zero rows fetched, selected, or processed\n`\n\nTo avoid problems, a DECLARE HANDLER statement is generally used. The HANDLER should handler the 1329 error, or the ''02000'' SQLSTATE, or the NOT FOUND error class.\n\nCursors can be declared for a prepared statement name, enabling full support for Dynamic SQL within stored routines. The SQL Standard syntax for  <dynamic declare cursor> is supported: a cursor is declared with the FOR clause to bind it to a prepared statement name, which is then prepared and opened normally. Cursors may also still SELECT from views, which can be created dynamically via prepared statements.&#x20;\n\nOnly SELECT statements are allowed for cursors, and they cannot be contained in a variable - so, they cannot be composed dynamically. However, it is possible to SELECT from a view. Since the CREATE VIEW statement can be executed as a prepared statement, it is possible to dynamically create the view that is queried by the cursor.&#x20;\n\nCursors can have parameters. Cursor parameters can appear in any part of the DECLARE CURSOR select_statement where a stored procedure variable is allowed (select list, WHERE, HAVING, LIMIT` etc). See DECLARE CURSOR and OPEN for syntax, and below for an example.\n\nCursors cannot have parameters.\n\nExamples\n--------\n\nCREATE TABLE c1(i INT);\n\nCREATE TABLE c2(i INT);\n\nCREATE TABLE c3(i INT);\n\nDELIMITER //\n\nCREATE PROCEDURE p1()\nBEGIN\n  DECLARE done INT DEFAULT FALSE;\n  DECLARE x, y INT;\n  DECLARE cur1 CURSOR FOR SELECT i FROM test.c1;\n  DECLARE cur2 CURSOR FOR SELECT i FROM test.c2;\n  DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;\n\n  OPEN cur1;\n  OPEN cur2;\n\n  read_loop: LOOP\n    FETCH cur1 INTO x;\n    FETCH cur2 INTO y;\n    IF done THEN\n      LEAVE read_loop;\n    END IF;\n    IF x < y THEN\n      INSERT INTO test.c3 VALUES (x);\n    ELSE\n      INSERT INTO test.c3 VALUES (y);\n    END IF;\n  END LOOP;\n\n  CLOSE cur1;\n  CLOSE cur2;\nEND; //\n\nDELIMITER ;\n\nINSERT INTO c1 VALUES(5),(50),(500);\n\nINSERT INTO c2 VALUES(10),(20),(30);\n\nCALL p1;\n\nSELECT  FROM c3;\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/programmatic-compound-statements-cursors/cursor-overview', '', 'https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/programmatic-compound-statements-cursors/cursor-overview');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (885, 35, 'DECLARE CURSOR', 'Syntax\n------\n\nDECLARE cursor_name CURSOR [(cursor_formal_parameter[,...])] FOR {select_statement | prepared_statement_name}\n\ncursor_formal_parameter:\n    [IN] name type [collate clause]\n\nDescription\n-----------\n\nThis statement declares a cursor. Multiple cursors may be declared in a stored program, but each cursor in a given block must have a unique name.\n\nselect_statement is not executed until the OPEN statement is executed. It is important to remember this if the query produces an error, or calls functions which have side effects.\n\nA SELECT associated to a cursor can use variables, but the query itself cannot be a variable, and cannot be dynamically composed. The SELECT statement cannot have an INTO clause.\n\nStarting with MariaDB 12.3, the query can also be a prepared statement name, which allows the query to be dynamically composed. The SELECT statement cannot have an INTO clause.\n\nCursors must be declared before HANDLERs, but after local variables and CONDITIONs.\n\n> The DECLARE CURSOR statement provides a cursor to a specified SELECT statement.\n>\n> To declare a cursor variable type that can be connected with multiple queries at runtime (REF CURSOR), use DECLARE TYPE... IS REF CURSOR in Oracle mode. See DECLARE TYPE.\n\nDynamic Cursors\n\nStarting with MariaDB 12.3, a cursor can be declared for a prepared statement. This allows the use of Dynamic SQL within stored routines. The cursor is bound to a prepared statement name, which must be defined using the PREPARE statement before the cursor is opened.\n\n``sql\nCREATE OR REPLACE PROCEDURE p1(tab VARCHAR(64), min_id INTEGER)\nBEGIN\n  DECLARE v_id INT;\n  DECLARE v_c1 VARCHAR(100);\n  DECLARE no_data BOOL DEFAULT FALSE;\n  \n  -- 1. Declare cursor for the statement name ''s1''\n  DECLARE c1 CURSOR FOR s1;\n  DECLARE CONTINUE HANDLER FOR NOT FOUND SET no_data = TRUE;\n\n  -- 2. Prepare the statement dynamically\n  PREPARE s1 FROM CONCAT(''SELECT id, c1 FROM '', tab, '' WHERE id >= ?'');\n  \n  -- 3. Open cursor and bind parameters\n  OPEN c1 USING min_id;\n  \n  fetch_loop: LOOP\n    FETCH c1 INTO v_id, v_c1;\n    IF no_data THEN\n      LEAVE fetch_loop;\n    END IF;\n    SELECT v_id, v_c1;\n  END LOOP;\n  \n  CLOSE c1;\n  DEALLOCATE PREPARE s1;\nEND;\n$$\n\nDELIMITER ;\n`\n\nParameters\n\nCursors can have parameters. This is a non-standard SQL extension. Cursor parameters can appear in any part of the DECLARE CURSOR select_statement where a stored procedure variable is allowed (select list, WHERE, HAVING, LIMIT , and so forth).\n\nIN\n\nThe IN qualifier is supported in the cursor_formal_parameter part of the syntax.\n\nThe IN qualifier is not supported in the cursor_formal_parameter` part of the syntax.\n\nSee Cursor Overview for an example.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/programmatic-compound-statements-cursors/declare-cursor', '', 'https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/programmatic-compound-statements-cursors/declare-cursor');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (886, 35, 'FETCH', 'Syntax\n------\n\nFETCH cursor_name INTO var_name [, var_name] ...\n\nDescription\n-----------\n\nThis statement fetches the next row (if a row exists) using the specified open cursor, and advances the cursor pointer.\n\nvar_name can be a local variable, but _not_ a user-defined variable.\n\nIf no more rows are available, a No Data condition occurs withSQLSTATE value 02000. To detect this condition, you can set up a handler for it (or for a NOT FOUND condition).\n\nSee Cursor Overview for an example.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/programmatic-compound-statements-cursors/fetch', '', 'https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/programmatic-compound-statements-cursors/fetch');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (887, 35, 'OPEN', 'Syntax\n------\n\nOPEN cursor_name [[USING variable[,...]] | [expression[,...]]];\n\nDescription\n-----------\n\nThis statement opens a cursor which was previously declared with DECLARE CURSOR.\n\nThe query associated to the DECLARE CURSOR is executed when OPEN is executed. It is important to remember this if the query produces an error, or calls functions which have side effects.\n\nThis is necessary in order to FETCH rows from a cursor.\n\nSee Cursor Overview for an example.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/programmatic-compound-statements-cursors/open', '', 'https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/programmatic-compound-statements-cursors/open');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (888, 35, 'Diagnostics Area', 'Description\n-----------\n\nThe diagnostics area contains information about the error conditions which were produced by an SQL statement, as well as some information about the statement which generated them.\n\nStatement Information\n\nThe statement information area contains the following data:\n\n NUMBER is the number of conditions which are present in the diagnostics area.\n ROW_COUNT has the same value as the ROW_COUNT() function for the statement that produced the conditions.\n\nCondition Information\n\nEach condition has several properties, which are explained here.\n\nData Types and Sizes\n\nThe following table shows the type and size of all the properties:\n\n| Property name       | Property type     |\n| ------------------- | ----------------- |\n| RETURNED_SQLSTATE  | VARCHAR(5)        |\n| MYSQL_ERRNO        | SMALLINT UNSIGNED |\n| MESSAGE_TEXT       | VARCHAR(512)      |\n| CLASS_ORIGIN       | VARCHAR(64)       |\n| SUBCLASS_ORIGIN    | VARCHAR(64)       |\n| CONSTRAINT_CATALOG | VARCHAR(64)       |\n| CONSTRAINT_SCHEMA  | VARCHAR(64)       |\n| CONSTRAINT_NAME    | VARCHAR(64)       |\n| CATALOG_NAME       | VARCHAR(64)       |\n| SCHEMA_NAME        | VARCHAR(64)       |\n| TABLE_NAME         | VARCHAR(64)       |\n| COLUMN_NAME        | VARCHAR(64)       |\n| CURSOR_NAME        | VARCHAR(64)       |\n\nThese properties can never be set to NULL. If they are empty, the empty string is used.\n\nCommon Condition Properties\n\nThe most common ones have a value for all built-in errors, and can be read both via SQL and via the API:\n\nRETURNED_SQLSTATE is the SQLSTATE of the condition. It is a five characters code, composed by a class (first two characters) and a subclass (last three characters). For more information about this property, refer to the SQLSTATE page.\n\nMYSQL_ERRNO is the error code. Each built-in condition has a unique numeric code. 0 indicates success, but it cannot be explicitly set or read via SQL. For a list of built-in error codes, refer to MariaDB Error Codes. The API function to read it is mysql_errno().\n\nMESSAGE_TEXT is a descriptive, human-readable message. For built-in errors, parsing this string is the only way to get more information about the error. For example, parsing a message like "Table ''tab1'' already exists", a program can find out that the missing table is tab1. The API function to read it is mysql_error().\n\nFor conditions generated by the user via SIGNAL, if MYSQL_ERRNO and MESSAGE_TEXT are not specified, their default values depend on the first two SQLSTATE characters:\n\n ''00'' means ''success''. It can not be set in any way, and can only be read via the API.\n For ''01'' class, default MYSQL_ERRNO is 1642 and default MESSAGE_TEXT is ''Unhandled user-defined warning condition''.\n For ''02'' class, default MYSQL_ERRNO is 1643 and default MESSAGE_TEXT is ''Unhandled user-defined not found condition''.\n For all other cases, including the ''45000'' value, default MYSQL_ERRNO is 1644 and default MESSAGE_TEXT is ''Unhandled user-defined exception condition''.\n\nSpecial Condition Properties\n\nThere are more condition properties, which are never set for built-in errors. They can only be set via SIGNAL and RESIGNAL statements, and can only be read via GET DIAGNOSTICS - not via the API. Such properties are:\n\nCLASS_ORIGIN indicates whether the SQLSTATE uses a standard class or a software-specific class. If it is defined in the SQL standards document ISO 9075-2 (section 24.1, SQLSTATE), this property''s value is supposed to be ''ISO 9075'', otherwise it is supposed to be ''MySQL''. However, any string is accepted.\n\nSUBCLASS_ORIGIN indicates whether the SQLSTATE uses a standard subclass or a software-specific class. If the SQLSTATE is defined in the SQL standards document ISO 9075-2 (section 24.1, SQLSTATE), this property''s value is supposed to be ''ISO 9075'', otherwise it is supposed to be ''MySQL''. However, any string is accepted.\n\nSCHEMA_NAME indicates in which schema (database) the error occurred.\n\nTABLE_NAME indicates the name of the table which was accessed by the failed statement.\n\nCOLUMN_NAME indicates the name of the column which was accessed by the failed statement.\n\nCONSTRAINT_NAME indicates the name of the constraint that was violated.\n\nCONSTRAINT_SCHEMA indicates in which schema the violated constraint is located.\n\nCURSOR_NAME indicates the name of the cursor which caused the error.\n\nThe following properties can be used and are defined in the standard SQL, but have no meaning because MariaDB doesn''t currently support catalogs:\n\nCATALOG_NAME is used by the standard SQL to indicate in which catalog the error occurred.\n\nCONSTRAINT_CATALOG is used by the standard SQL to indicate in which catalog the violated constraint is located.\n\nHow the Diagnostics Area is Populated and Cleared\n\nWhen a statement produces one or more error conditions (errors, warnings, notes) the conditions are inserted into the diagnostics area, and the statement information area is updated with that statement’s information. Usually, this also clears all the old conditions from the diagnostics area, but there is an exception: if the new statement is a correctly parsed RESIGNAL or GET DIAGNOSTICS, the old contents will remain in the diagnostics area. SIGNAL clears the old conditions.\n\nWhen a table-based statement (like INSERT) is executed, the old data in the diagnostics area is cleared even if the statement doesn''t produce any condition. However, statements which don''t access any table (like SET, or a SELECT with no FROM clause) is executed and produces no warnings, the diagnostics area remains unchanged.\n\nThe maximum number of conditions that can be in the diagnostics area is max_error_count. If this value is 0, the diagnostics area is empty. If this variable is changed, the new value takes effect with the next statement (that is, the diagnostics area is not immediately truncated).\n\nHow to Access the Diagnostics Area\n\nThe following statements explicitly add conditions to the diagnostics area:\n\n SIGNAL: produces a custom error.\n RESIGNAL: after an error is produced, generates a modified version of that error.\n\nThe following statements read contents from the diagnostics area:\n\n GET DIAGNOSTICS is the only way to read all information.\n SHOW WARNINGS shows a summary of errors, warnings and notes.\n* SHOW ERRORS shows a summary of errors.\n\nDECLARE HANDLER can be used to handle error conditions within stored programs.\n\nDECLARE CONDITION can be used to associate an SQLSTATE or an error code to a name. That name can be referenced in DECLARE HANDLER, SIGNAL and RESIGNAL statements.\n\nAll these statements can also be executed inside a stored routine. However, only SHOW WARNINGS and SHOW ERRORS can be executed as a prepared statement. After an EXECUTE statement, the diagnostics area contains information about the prepared statement, if it produces error conditions.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/programmatic-compound-statements-diagnostics/diagnostics-area', '', 'https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/programmatic-compound-statements-diagnostics/diagnostics-area');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (889, 35, 'GET DIAGNOSTICS', 'Description\n-----------\n\n``sql\nGET [CURRENT] DIAGNOSTICS\n{\n    statement_property\n    [, statement_property] ... \n  | CONDITION condition_number\n    condition_property\n    [, condition_property] ...\n}\n\nstatement_property:\n    variable = statement_property_name\n\ncondition_property:\n    variable  = condition_property_name\n\nstatement_property_name:\n    NUMBER\n  | ROW_COUNT\n\ncondition_property_name:\n    CLASS_ORIGIN\n  | SUBCLASS_ORIGIN\n  | RETURNED_SQLSTATE\n  | MESSAGE_TEXT\n  | MYSQL_ERRNO\n  | CONSTRAINT_CATALOG\n  | CONSTRAINT_SCHEMA\n  | CONSTRAINT_NAME\n  | CATALOG_NAME\n  | SCHEMA_NAME\n  | TABLE_NAME\n  | COLUMN_NAME\n  | CURSOR_NAME\n  | ROW_NUMBER\n`\n\nThe diagnostics area contains information about the errors, warnings and notes which were produced by the last SQL statement. If that statement didn''t produce any warnings, the diagnostics area contains information about the last executed statement which involved a table. The GET DIAGNOSTICS statement copies the requested information from the diagnostics area to the specified variables. It is possible to use both user variables or local variables.\n\nTo use GET DIAGNOSTICS, it is important to know how the diagnostics area is structured. It has two sub-areas: the statement information area and the error conditions information area. For details, please refer to the diagnostics area page.\n\nEach single GET DIAGNOSTICS command can read information from the statement information area or from a single error condition. This means that, if you have two warnings and you want to know the number of warnings, and read both the warnings, you need to issue GET DIAGNOSTICS three times.\n\nThe CURRENT keywords adds nothing to the statement, because MariaDB has only one diagnostics area.\n\nIf GET DIAGNOSTICS produces an error condition (because the command is properly parsed but not correctly used), the diagnostics area is not emptied, and the new condition is added.\n\nGetting Information from a Condition\n\nTo read information from a condition, the CONDITION keyword must be specified and it must be followed by the condition number. This number can be specified as a constant value or as a variable. The first condition''s index is 1. If the error condition does not exist, the variables will not change their value and a 1758 error will be produced ("Invalid condition number").\n\nThe condition properties that can be read with GET DIAGNOSTICS are the same that can be set with SIGNAL and RESIGNAL statements. They are explained in the diagnostics area page. However, there is one more property: RETURNED_SQLSTATE, which indicates the condition''s SQLSTATE.\n\nFor a list of SQLSTATE values and MariaDB error codes, see MariaDB Error Codes.\n\nThe type for all the condition properties is VARCHAR(64), except for MYSQL_ERRNO, whose valid range is 1 to 65534.\n\nROW_NUMBER\n\nYou can use the ROW_NUMBER property to retrieve the row number, too, even if the error text does not mention it. This property is named ERROR_INDEX . ROW_NUMBER is a reserved word.\n\nThere is no way, short of parsing the error text, to know in what row an error had happened.\n\nExamples\n--------\n\nCREATE TABLE test.t (c` INT) ENGINE = x;\nQuery OK, 0 rows affected, 2 warnings (0.19 sec)\n\nGET DIAGNOSTICS @num_conditions = NUMBER;\n\nSELECT @num_conditions;\n+-----------------+\n| @num_conditions |\n+-----------------+\n|               2 |\n+-----------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/programmatic-compound-statements-diagnostics/get-diagnostics', '', 'https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/programmatic-compound-statements-diagnostics/get-diagnostics');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (890, 35, 'SQLSTATE', 'Description\n-----------\n\nSQLSTATE is a code which identifies SQL error conditions. It composed by five characters, which can be numbers or uppercase ASCII letters. An SQLSTATE value consists of a class (first two characters) and a subclass (last three characters).\n\nThere are three important standard classes. They all indicate in which logical group of errors the condition falls. They match to a particular keyword which can be used with DECLARE HANDLER. Also, the SQLSTATE class determines the default value for the MYSQL_ERRNO and MESSAGE_TEXT condition properties.\n\n ''00'' means ''success''. It can not be set in any way and can only be read via the API.\n ''01'' contains all warnings and matches to the SQLWARNING keyword. The default MYSQL_ERRNO is 1642 and default MESSAGE_TEXT is ''Unhandled user-defined warning condition''.\n ''02'' is the NOT FOUND class. The default MYSQL_ERRNO is 1643 and default MESSAGE_TEXT is ''Unhandled user-defined not found condition''.\n All other classes match the SQLEXCEPTION keyword. The default MYSQL_ERRNO is 1644 and default MESSAGE_TEXT is ''Unhandled user-defined exception condition''.\n\nThe subclass, if it is set, indicates a particular condition, or a particular group of conditions within the class. However, the ''000'' sequence means ''no subclass''.\n\nFor example, if you try to SELECT from a table which does not exist, a 1109 error is produced, with a ''42S02'' SQLSTATE. ''42'' is the class and ''S02'' is the subclass. This value matches to the SQLEXCEPTION keyword. When FETCH is called for a cursor which has already reached the end, a 1329 error is produced, with a ''02000'' SQLSTATE. The class is ''02'' and there is no subclass (because ''000'' means ''no subclass''). It can be handled by a NOT FOUND handlers.\n\nThe standard SQL specification says that classes beginning with 0, 1, 2, 3, 4, A, B, C, D, E, F and G are reserved for standard-defined classes, while other classes are vendor-specific. It also says that, when the class is standard-defined, subclasses starting with those characters (except for ''000'') are standard-defined subclasses, while other subclasses are vendor-defined. However, MariaDB and MySQL do not strictly obey this rule.\n\nTo read the SQLSTATE of a particular condition which is in the diagnostics area, the GET DIAGNOSTICS statement can be used: the property is called RETURNED_SQLSTATE. For user-defined conditions (SIGNAL and RESIGNAL statements), a SQLSTATE value must be set via the SQLSTATE clause. However, SHOW WARNINGS and SHOW ERRORS do not display the SQLSTATE.\n\nFor user-defined conditions, MariaDB and MySQL recommend the ''45000'' SQLSTATE class.\n\n''HY000'' is called the "general error": it is the class used for built-in conditions which do not have a specific SQLSTATE class.\n\nA partial list of error codes and matching SQLSTATE values can be found under MariaDB Error Codes.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/programmatic-compound-statements-diagnostics/sqlstate', '', 'https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/programmatic-compound-statements-diagnostics/sqlstate');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (891, 35, 'REPEAT LOOP', 'Description\n-----------\n\nSyntax\n\n``sql\n[begin_label:] REPEAT\n    statement_list\nUNTIL search_condition\nEND REPEAT [end_label]\n`\n\nThe statement list within a REPEAT statement is repeated until the search_condition is true. Thus, a REPEAT always enters the loop at least once. statement_list consists of one or more statements, each\\\nterminated by a semicolon (i.e., ;) statement delimiter.\n\nA REPEAT statement can be labeled. end_label cannot be given unless begin_label is also present. If both are present, they must be the same.\n\nSee Delimiters in the mariadb client for more on client delimiter usage.\n\n`sql\nDELIMITER //\n\nCREATE PROCEDURE dorepeat(p1 INT)\n  BEGIN\n    SET @x = 0;\n    REPEAT SET @x = @x + 1; UNTIL @x > p1 END REPEAT;\n  END\n//\n\nCALL dorepeat(1000)//\n\nSELECT @x//\n+------+\n| @x   |\n+------+\n| 1001 |\n+------+\n``\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/repeat-loop', '', 'https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/repeat-loop');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (892, 35, 'RESIGNAL', 'Syntax\n------\n\nRESIGNAL [error_condition]\n    [SET error_property\n    [, error_property] ...]\n\nerror_condition:\n    SQLSTATE [VALUE] ''sqlstate_value''\n  | condition_name\n\nerror_property:\n    error_property_name = <error_property_value>\n\nerror_property_name:\n    CLASS_ORIGIN\n  | SUBCLASS_ORIGIN\n  | MESSAGE_TEXT\n  | MYSQL_ERRNO\n  | CONSTRAINT_CATALOG\n  | CONSTRAINT_SCHEMA\n  | CONSTRAINT_NAME\n  | CATALOG_NAME\n  | SCHEMA_NAME\n  | TABLE_NAME\n  | COLUMN_NAME\n  | CURSOR_NAME\n\nDescription\n-----------\n\nThe syntax of RESIGNAL and its semantics are very similar to SIGNAL. This statement can only be used within an error HANDLER. It produces an error, like SIGNAL. RESIGNAL clauses are the same as SIGNAL, except that they all are optional, even SQLSTATE. All the properties which are not specified in RESIGNAL, will be identical to the properties of the error that was received by the error HANDLER. For a description of the clauses, see diagnostics area.\n\nRESIGNAL does not empty the diagnostics area. It just appends another error condition.\n\nRESIGNAL, without any clauses, produces an error which is identical to the error that was received by HANDLER.\n\nIf used out of a HANDLER construct, RESIGNAL produces the following error:\n\n``sql\nERROR 1645 (0K000): RESIGNAL when handler not active\n`\n\nIf a HANDLER contains a CALL to another procedure, that procedure can use RESIGNAL, but trying to do this raises the above error.\n\nIf a HANDLER contains a CALL to another procedure, that procedure can use RESIGNAL.\n\nFor a list of SQLSTATE values and MariaDB error codes, see MariaDB Error Codes.\n\nThe following procedure tries to query two tables which don''t exist, producing a 1146 error in both cases. Those errors will trigger the HANDLER. The first time the error will be ignored, and the client will not receive it, but the second time, the error is re-signaled, so the client will receive it.\n\n`sql\nCREATE PROCEDURE test_error( )\nBEGIN\n   DECLARE CONTINUE HANDLER\n      FOR 1146\n   BEGIN\n   IF @hide_errors IS FALSE THEN\n      RESIGNAL;\n   END IF;\n   END;\n   SET @hide_errors = TRUE;\n   SELECT ''Next error will be ignored'' AS msg;\n   SELECT c FROM temptab_one;\n   SELECT ''Next error won''''t be ignored'' AS msg;\n   SET @hide_errors = FALSE;\n   SELECT c FROM temptab_two;\nEND;\n\nCALL test_error( );\n\n+----------------------------+\n| msg                        |\n+----------------------------+\n| Next error will be ignored |\n+----------------------------+\n\n+-----------------------------+\n| msg                         |\n+-----------------------------+\n| Next error won''t be ignored |\n+-----------------------------+\n\nERROR 1146 (42S02): Table ''test.temptab_two'' doesn''t exist\n`\n\nThe following procedure re-signals an error, modifying only the error message to clarify the cause of the problem.\n\n`sql\nCREATE PROCEDURE test_error()\nBEGIN\n   DECLARE CONTINUE HANDLER\n   FOR 1146\n   BEGIN\n      RESIGNAL SET\n      MESSAGE_TEXT = ''temptab does not exist'';\n   END;\n   SELECT c FROM temptab;\nEND;\n\nCALL test_error( );\nERROR 1146 (42S02): temptab does not exist\n`\n\n`sql\nCREATE PROCEDURE handle_error()\nBEGIN\n  RESIGNAL;\nEND;\nCREATE PROCEDURE p()\nBEGIN\n  DECLARE EXIT HANDLER FOR SQLEXCEPTION CALL p();\n  SIGNAL SQLSTATE ''45000'';\nEND;\n``\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/resignal', '', 'https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/resignal');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (893, 35, 'RETURN', 'Description\n-----------\n\nSyntax\n\n``sql\nRETURN expr\n`\n\nThe RETURN statement terminates execution of a stored function and returns the value _expr_ to the function caller. There must be at least one RETURN statement in a stored function. If the function has multiple exit points, all exit points must have a RETURN.\n\nThis statement is not used in stored procedures, triggers, or events. LEAVE can be used instead.\n\nThe following example shows that RETURN can return the result of a scalar subquery:\n\n`sql\nCREATE FUNCTION users_count() RETURNS BOOL\n   READS SQL DATA\nBEGIN\n   RETURN (SELECT COUNT(DISTINCT User) FROM mysql.user);\nEND;\n``\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/return', '', 'https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/return');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (894, 35, 'SELECT INTO', 'Syntax\n------\n\nSELECT col_name [, col_name] ...\n    INTO var_name [, var_name] ...\n    table_expr\n\nDescription\n-----------\n\nSELECT ... INTO enables selected columns to be stored directly into variables. No resultset is produced. The query should return a single row. If the query returns no rows, a warning with error code 1329 occurs (No data), and the variable values remain unchanged. If the query returns multiple rows, error 1172 occurs (Result consisted of more than one row). If it is possible that the statement may retrieve multiple rows, you can useLIMIT 1 to limit the result set to a single row.\n\nThe INTO clause can also be specified at the end of the statement.\n\nIn the context of such statements that occur as part of events executed by the Event Scheduler, diagnostics messages (not only errors, but also warnings) are written to the error log, and, on\\\nWindows, to the application event log.\n\nThis statement can be used with both local variables and user-defined variables.\n\nFor the complete syntax, see SELECT.\n\nAnother way to set a variable''s value is the SET statement.\n\nSELECT ... INTO results are not stored in the query cache even if SQL_CACHE is specified.\n\nExamples\n--------\n\nSELECT id, data INTO @x,@y \nFROM test.t1 LIMIT 1;\nSELECT * FROM t1 WHERE t1.a=@x AND t1.b=@y\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/selectinto', '', 'https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/selectinto');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (895, 35, 'SET Variable', 'Syntax\n------\n\nSET var_name = expr [, var_name = expr] ...\n\nDescription\n-----------\n\nThe SET statement in stored programs is an extended version of the general SET statement. Referenced variables may be ones declared inside a stored program, global system variables, or user-defined variables.\n\nThe SET statement in stored programs is implemented as part of the pre-existing SET syntax. This allows an extended syntax of SET a=x, b=y, ... where different variable types (locally declared variables, global and session server variables, user-defined variables) can be mixed. This also allows combinations of local variables and some options that make sense only for system variables; in that case, the options are recognized but ignored.\n\nSET can be used with both local variables and user-defined variables.\n\nWhen setting several variables using the columns returned by a query, SELECT INTO should be preferred.\n\nTo set many variables to the same value, the LAST_VALUE( ) function can be used.\n\nBelow is an example of how a user-defined variable may be set:\n\n``sql\nSET @x = 1;\n``\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/set-variable', '', 'https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/set-variable');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (896, 35, 'SIGNAL', 'Description\n-----------\n\nSyntax\n\n``sql\nSIGNAL error_condition\n    [SET error_property\n    [, error_property] ...]\n\nerror_condition:\n    SQLSTATE [VALUE] ''sqlstate_value''\n  | condition_name\n\nerror_property:\n    error_property_name = <error_property_value>\n\nerror_property_name:\n    CLASS_ORIGIN\n  | SUBCLASS_ORIGIN\n  | MESSAGE_TEXT\n  | MYSQL_ERRNO\n  | CONSTRAINT_CATALOG\n  | CONSTRAINT_SCHEMA\n  | CONSTRAINT_NAME\n  | CATALOG_NAME\n  | SCHEMA_NAME\n  | TABLE_NAME\n  | COLUMN_NAME\n  | CURSOR_NAME\n`\n\nSIGNAL empties the diagnostics area and produces a custom error. This statement can be used anywhere but is generally useful when used inside a stored program. When the error is produced, it can be caught by a HANDLER. If not, the current stored program, or the current statement, will terminate with the specified error.\n\nSometimes an error HANDLER just needs to SIGNAL the same error it received, optionally with some changes. Usually, the RESIGNAL statement is the most convenient way to do this.\n\nerror_condition can be an SQLSTATE value, or a named error condition defined via DECLARE CONDITION. SQLSTATE must be a constant string consisting of five characters. These codes are standard to ODBC and ANSI SQL. For customized errors, the recommended SQLSTATE is ''45000''. For a list of SQLSTATE values used by MariaDB, see the MariaDB Error Codes page. The SQLSTATE can be read via the API method mysql_sqlstate( ).\n\nTo specify error properties user-defined variables and local variables can be used, as well as character set conversions (but you can''t set a collation).\n\nThe error properties, their type and their default values are explained in the diagnostics area page.\n\nErrors\n\nIf the SQLSTATE is not valid, the following error like this will be produced:\n\n`sql\nERROR 1407 (42000): Bad SQLSTATE: ''123456''\n`\n\nIf a property is specified more than once, an error like this will be produced:\n\n`sql\nERROR 1641 (42000): Duplicate condition information item ''MESSAGE_TEXT''\n`\n\nIf you specify a condition name which is not declared, an error like this will be produced:\n\n`sql\nERROR 1319 (42000): Undefined CONDITION: cond_name\n`\n\nIf MYSQL_ERRNO is out of range, you will get an error like this:\n\n`sql\nERROR 1231 (42000): Variable ''MYSQL_ERRNO'' can''t be set to the value of ''0''\n``\n\nExamples\n--------\n\nSIGNAL SQLSTATE ''01000'';\nQuery OK, 0 rows affected, 1 warning (0.00 sec)\n\nSHOW WARNINGS;\n\n+---------+------+------------------------------------------+\n| Level   | Code | Message                                  |\n+---------+------+------------------------------------------+\n| Warning | 1642 | Unhandled user-defined warning condition |\n+---------+------+------------------------------------------+\n1 row in set (0.06 sec)\n\nSIGNAL SQLSTATE ''02000'';\nERROR 1643 (02000): Unhandled user-defined not found condition\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/signal', '', 'https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/signal');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (897, 35, 'Using Compound Statements Outside of Stored Programs', 'Description\n-----------\n\nCompound statements can also be used outside of stored programs.\n\n``sql\ndelimiter |\nIF @have_innodb THEN\n  CREATE TABLE IF NOT EXISTS innodb_index_stats (\n    database_name    VARCHAR(64) NOT NULL,\n    table_name       VARCHAR(64) NOT NULL,\n    index_name       VARCHAR(64) NOT NULL,\n    last_update      TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n    stat_name        VARCHAR(64) NOT NULL,\n    stat_value       BIGINT UNSIGNED NOT NULL,\n    sample_size      BIGINT UNSIGNED,\n    stat_description VARCHAR(1024) NOT NULL,\n    PRIMARY KEY (database_name, table_name, index_name, stat_name)\n  ) ENGINE=INNODB DEFAULT CHARSET=utf8 COLLATE=utf8_bin STATS_PERSISTENT=0;\nEND IF|\nQuery OK, 0 rows affected, 2 warnings (0.00 sec)\n`\n\nUsing compound statements this way is subject to following limitations:\n\n Only BEGIN, IF, CASE, LOOP, WHILE, REPEAT statements may start a compound statement outside of stored programs.\n BEGIN must use the BEGIN NOT ATOMIC syntax (otherwise it''ll be confused with BEGIN that starts a transaction).\n A compound statement might not start with a label.\n A compound statement is parsed completely—note "2 warnings" in the above example, even if the condition was false (InnoDB was, indeed, disabled), and the CREATE TABLE statement was not executed, it was still parsed and the parser produced "Unknown storage engine" warning.\n\nInside a compound block first three limitations do not apply, one can use anything that can be used inside a stored program — including labels, condition handlers, variables, and so on:\n\n`sql\nBEGIN NOT ATOMIC\n    DECLARE foo CONDITION FOR 1146;\n    DECLARE x INT DEFAULT 0;\n    DECLARE CONTINUE HANDLER FOR SET x=1;\n    INSERT INTO test.t1 VALUES ("hndlr1", val, 2);\n    END|\n`\n\nExample how to use IF:\n\n`sql\nIF (1>0) THEN BEGIN NOT ATOMIC SELECT 1; END ; END IF;;\n`\n\nExample of how to use WHILE loop:\n\n`sql\nDELIMITER |\nBEGIN NOT ATOMIC\n    DECLARE x INT DEFAULT 0;\n    WHILE x <= 10 DO\n        SET x = x + 1;\n        SELECT x;\n    END WHILE;\nEND|\nDELIMITER ;\n``\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/using-compound-statements-outside-of-stored-programs', '', 'https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/using-compound-statements-outside-of-stored-programs');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (898, 35, 'WHILE', 'Syntax\n------\n\n[begin_label:] WHILE search_condition DO\n    statement_list\nEND WHILE [end_label]\n\nDescription\n-----------\n\nThe statement list within a WHILE statement is repeated as long as thesearch_condition is true. statement_list consists of one or more statements. If the loop must be executed at least once, REPEAT ... LOOP can be used instead.\n\nA WHILE statement can be labeled. end_label cannot be given unless begin_label also is present. If both are present, they must be the same.\n\nExamples\n--------\n\nCREATE PROCEDURE dowhile()\nBEGIN\n  DECLARE v1 INT DEFAULT 5;\n\n  WHILE v1 > 0 DO\n    ...\n    SET v1 = v1 - 1;\n  END WHILE;\nEND\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/while', '', 'https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/while');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (899, 35, 'Stored Routine Statements', 'Description\n-----------\n\ncall.md\n\nInvoke a stored procedure. This statement executes a previously created stored procedure, optionally passing parameters and returning results.\n\ndo.md\n\nExecute expressions without returning a result set. This statement runs functions or expressions, often used for side effects like releasing locks.\n\ncreate-procedure.md\n\nDefine a new stored procedure, specifying its name, parameters (IN, OUT, INOUT), and the SQL statements it executes.\n\nalter-procedure.md\n\nModify the characteristics of an existing stored procedure, such as its security context or comment, without changing its logic.\n\ndrop-procedure.md\n\nRemove a stored procedure and its associated privileges from the database.\n\ndrop-function.md\n\nRemove a stored function from the database, deleting its definition and associated privileges.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/stored-routine-statements/README', '', 'https://mariadb.com/docs/server/reference/sql-statements/stored-routine-statements/README');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (900, 35, 'CALL', 'Syntax\n------\n\nCALL sp_name([parameter[,...]])\nCALL sp_name[()]\n\nDescription\n-----------\n\nThe CALL statement invokes a stored procedure that was defined previously with CREATE PROCEDURE.\n\nStored procedure names can be specified as database_name.procedure_name. Procedure names and database names can be quoted with backticks (). This is necessary if they are reserved words, or contain special characters. See identifier qualifiers for details.\n\nCALL p() and CALL p are equivalent.\n\nIf parentheses are used, any number of spaces, tab characters and newline characters are allowed between the procedure''s name and the open parenthesis.\n\nCALL can pass back values to its caller using parameters that are declared as OUT or INOUT\\\nparameters. If no value is assigned to an OUT parameter, NULL is assigned (and its former value is lost). To pass such values from another stored program you can use user-defined variables, local variables or routine''s parameters; in other contexts, you can only use user-defined variables.\n\nCALL can also be executed as a prepared statement. Placeholders can be used for IN parameters in all versions of MariaDB; for OUT and INOUT parameters, placeholders can be used since MariaDB 5.5.\n\nWhen the procedure returns, a client program can also obtain the number of rows affected for the final statement executed within the routine: At the SQL level, call the ROW_COUNT() function; from the C\\\nAPI, call the mysql_affected_rows() function.\n\nIf the CLIENT_MULTI_RESULTS API flag is set, CALL can return any number of result sets and the called stored procedure can execute prepared statements. If it is not set, at most one result set can be returned and prepared statements cannot be used within procedures.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/stored-routine-statements/call', '', 'https://mariadb.com/docs/server/reference/sql-statements/stored-routine-statements/call');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (901, 35, 'DO', 'Syntax\n------\n\nDO expr [, expr] ...\n\nDescription\n-----------\n\nDO executes the expressions but does not return any results. In most respects, DO is shorthand forSELECT expr, ..., but has the advantage that it is slightly faster when you do not care about the result.\n\nDO is useful primarily with functions that have side effects, such as RELEASE_LOCK().\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/stored-routine-statements/do', '', 'https://mariadb.com/docs/server/reference/sql-statements/stored-routine-statements/do');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (902, 35, 'Table Statements', 'Description\n-----------\n\nalter\n\nAccess the reference for ALTER statements. This section lists commands to modify existing database objects, including tables, databases, users, and servers.\n\nalter-table\n\nComplete ALTER TABLE guide for MariaDB. Complete syntax for modifying columns, indexes, constraints, and table properties with comprehensive examples.\n\nanalyze-table.md\n\nAnalyze and store key distribution. This statement updates index statistics used by the optimizer to choose the best execution plan.\n\ncheck-table.md\n\nCheck tables or views for errors. This statement verifies the integrity of table structure and data for supported storage engines.\n\ncheck-view.md\n\nVerify the validity of a view''s algorithm. This statement checks if the view definition is correct and references existing tables.\n\nchecksum-table.md\n\nReport a checksum for table contents. This statement calculates a value to compare tables, useful for verifying replication consistency.\n\ncreate-table.md\n\nComplete guide to creating tables in MariaDB. Complete CREATE TABLE syntax for data types, constraints, indexes, and storage engines for production use.\n\ndelete.md\n\nComplete guide to deleting data in MariaDB. Complete DELETE syntax with WHERE filtering, JOIN operations, and safety considerations for production use.\n\ndrop-table.md\n\nComplete DROP TABLE syntax: TEMPORARY, IF EXISTS, WAIT/NOWAIT, RESTRICT/CASCADE options, metadata locks, atomic DROP, and replication behavior.\n\ninsert.md\n\nComplete guide to inserting data in MariaDB. Complete INSERT syntax for single rows, bulk operations, and ON DUPLICATE KEY handling for production use.\n\noptimize-table.md\n\nComplete MariaDB performance optimization guide. Complete reference for query tuning, indexing strategies, and configuration improvements for production use.\n\nrename-table.md\n\nChange the name of one or more tables atomically. This command moves tables within or between databases while preserving their data and structure.\n\nrepair-table.md\n\nRepair corrupted tables. This statement fixes errors in tables for supported storage engines like MyISAM, Aria, and Archive.\n\nrepair-view.md\n\nCheck and correct a view''s algorithm. This statement is primarily used by upgrade scripts to ensure view definitions are compatible.\n\nreplace.md\n\nInsert or replace rows based on unique keys. This statement acts like INSERT, but if a duplicate key exists, it deletes the old row and inserts the new one.\n\nshow-columns.md\n\nComplete guide to displaying table columns in MariaDB. Complete SHOW COLUMNS syntax with field types, keys, and filtering options for production use.\n\nshow-create-table.md\n\nGet the SQL statement to recreate a table. This statement shows the complete CREATE TABLE syntax, including column definitions and indexes.\n\nshow-index.md\n\nComplete SHOW INDEX reference: SHOW INDEX FROM _tbl_name_ syntax, output fields, and WHERE/LIKE filters.\n\ntruncate-table.md\n\nComplete TRUNCATE TABLE reference with [WAIT n|NOWAIT] syntax, InnoDB FOREIGN KEY constraints, implicit commit, and AUTO_INCREMENT reset.\n\nupdate.md\n\nComplete UPDATE statement guide for MariaDB. Complete syntax reference with WHERE conditions, JOIN operations, and multi-table updates for production use.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/table-statements/README', '', 'https://mariadb.com/docs/server/reference/sql-statements/table-statements/README');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (903, 35, 'ANALYZE TABLE', 'Syntax\n------\n\nANALYZE [NO_WRITE_TO_BINLOG | LOCAL] TABLE tbl_name [,tbl_name ...]\n  [PERSISTENT FOR \n    { ALL\n      | COLUMNS ([col_name [,col_name ...]]) INDEXES ([index_name [,index_name ...]])\n    }\n  ]\n\nDescription\n-----------\n\nANALYZE TABLE analyzes and stores the key distribution for a table (index statistics). This statement works with MyISAM, Aria, and InnoDB tables. During the analysis, InnoDB will allow reads/writes, and MyISAM/Aria reads/inserts. For MyISAM tables, this statement is equivalent to using myisamchk --analyze.\n\nANALYZE uses histograms, which can provide a better selectivity than InnoDB statistics offer. InnoDB statistics work with a limited sample set and are therefore not as accurate as persistent statistics can be. For more information on how the analysis works within InnoDB, see InnoDB Limitations.\n\nMariaDB uses the stored key distribution to decide the order in which tables should be joined when you perform a join on something other than a constant. In addition, key distributions can be used when deciding which indexes to use for a specific table within a query.\n\nThis statement requires SELECT and INSERT privileges for the table.\n\nBy default, ANALYZE TABLE statements are written to the binary log and will be replicated. The NO_WRITE_TO_BINLOG keyword (LOCAL is an alias) will ensure the statement is not written to the binary log.\n\nANALYZE TABLE statements are not logged to the binary log if read_only is set. See also Read-Only Slaves.\n\nANALYZE TABLE is non-blocking and non-intrusive. A connection will start using new statistics for the query following the completion of the ANALYZE TABLE.\n\nANALYZE TABLE is blocking and intrusive.\n\nANALYZE TABLE is also supported for partitioned tables. You can use ALTER TABLE ... ANALYZE PARTITION to analyze one or more partitions.\n\nThe Aria storage engine supports progress reporting for the ANALYZE TABLE statement.\n\nSkipping Long CHAR/VARCHAR Columns\n\nWhen using ANALYZE TABLE PERSISTENT, MariaDB skips long CHAR/VARCHAR columns during statistics collection if they exceed the value of the analyze_max_length system variable.\n\nThis prevents excessive disk usage when analyzing tables with large text columns.\n\n If a column is longer than analyze_max_length, it is excluded from stats.\n If a long column is explicitly specified in FOR COLUMNS(), it is still analyzed, regardless of its size.\n\nExample:\n\n``sql\nSET GLOBAL analyze_max_length = 50000;\nANALYZE TABLE large_text_table PERSISTENT;\n`\n\n`sql\nANALYZE TABLE large_text_table PERSISTENT FOR COLUMNS(long_description);\n`\n\n`sql\nCREATE TABLE product_data (\n    id INT PRIMARY KEY,\n    name VARCHAR(100),\n    description VARCHAR(50000), -- long column\n    specs VARCHAR(1000)\n);\n\n-- Set limit\nSET SESSION analyze_max_length = 10000;\n\n-- Run analysis without explicitly selecting columns\nANALYZE TABLE product_data PERSISTENT;\n\n-- ''description'' will be skipped due to length > 10000\n\n-- To include it anyway\nANALYZE TABLE product_data PERSISTENT FOR COLUMNS(description);\n`\n\nThe functionality for skipping long CHAR and VARCHAR columns isn''t available.\n\nPerformance Impact\n\nNote that analyzing tables with ANALYZE can have a performance impact and can use a lot of disk space for big tables. As column statistics usually do not change much over time, even when the table grows, there is no benefit to running ANALYZE very often.\n\nRunning ANALYZE is indicated:\n\n for newly populated tables,\n for tables that have additional columns added that are used in WHERE clauses,\n when a table has doubled in size,\n when you note that a query becomes slow because the table order has changed, and you can see from EXPLAIN or ANALYZE FORMAT=JSON that the selectivity is wrong for a table,\n when the distribution of data in a table has changed significantly, for example, if you have loaded a batch of data or deleted a large amount of data.\n\nANALYZE isn’t useful for table columns of type UNIQUE, PRIMARY KEY, TIME, or CURRENT_TIME. In ANALYZE queries, you should omit columns of those types.\n\nEITS Statistics / PERSISTENT FOR\n\nOverview\n\nANALYZE TABLE supports engine-independent table statistics (EITS). See Engine-Independent Table Statistics: Collecting Statistics with the ANALYZE TABLE Statement for more information.\n\nYou can run the statement on all columns with this statement — however, be aware that this can take a long time for very large (500+ GB) tables:\n\n`sql\nANALYZE TABLE tbl PERSISTENT FOR ALL\n`\n\nFocusing on particular columns, the statement looks like this — it collects statistics only for the specified table columns:\n\n`sql\nANALYZE TABLE tbl PERSISTENT FOR COLUMS (column1, column2, ...) INDEXES (index1, ...)\n`\n\nFocusing on columns helps, among other things, avoid including BLOB columns, for which MariaDB doesn''t collect statistics.\n\nIt''s recommended to collect statistics for columns that do _not_ have an index starting from that column (if the index starts with a column, the index itself is used as a source for statistics), and which are used in WHERE conditions of your queries.\n\nQueries That Benefit\n\nQueries that benefit most are those where the query plan depends on the optimizer knowing condition selectivities, the most important ones being JOIN queries and those with an ORDER BY ... LIMIT clause. To benefit, the query must have a condition that may or may not be selective, for example:\n\n`sql\nSELECT \nFROM orders, customer\nWHERE\n       orders.o_custkey = customer.c_custkey  -- join condition\n  AND  customer.c_area = ''EMEA''  -- (1)\n  AND  orders.o_priority= ''URGENT'' -- (2)\n`\n\nHere, the optimizer benefits from knowing these statistics:\n\n1. Which fraction of customers are in the EMEA region?\n2. Which fraction of orders are URGENT?\n\nFor that situation, you can issue this statement:\n\n`sql\nANALYZE TABLE orders, customer PERSISTENT FOR ALL\n`\n\nEITS vs. InnoDB-Internal Statistics\n\nEITS (engine-independent table statistics) provide way more data than InnoDB-internal statistics. The downside is that EITS are never automatically updated, and it takes time to collect them.\n\nInnoDB statistics, on the other hand, provide less data, but they are automatically updated.\n\nControlling Statistics\n\nEngine-independent statistics can be controlled (enabled and disabled) using the use_stat_tables variable and the optimizer_use_condition_selectivity variable. InnoDB-persistent statistics are controlled with the innodb_stats_persistent variable (allowing you to turn InnoDB statistics on or off). Combining both kinds of statistics is possible.\n\nThe server relies on InnoDB statistics by default. That way, it can use some statistics even if ANALYZE TABLE is never run (or not often enough). This gives good enough results for the majority of queries. Some queries, however, need more statistical data so the optimizer can create a good plan. Slow queries indicate there aren''t enough statistical data. Those queries can be accelerated by running ANALYZE TABLE tbl PERSISTENT FOR ..., where tbl indicates a table used by a slow query. You can also run ANALYZE TABLE ... PERSISTENT FOR ALL, but that has a significant performance impact.\n\nUseful Variables\n\nThe following overview indicates when a particular variable was introduced. When multiple versions are given, it means variable options (like the default value) changed between the indicated versions.\n\n| Variable                                                                                                                                                  | Introduced in MariaDB version                                  | Description                                                                                                                                                                                                                                                                                                                                            |\n| --------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| analyze_max_length                | MariaDB 10.6.23 / 10.11.14 / 11.4.8 / 11.8.3 / 12.0.2 / 12.1.1 | Prevents the collection of column statistics for CHAR/VARCHAR columns that can be analyzed automatically by ANALYZE TABLE PERSISTENT. Columns exceeding this threshold in bytes will be skipped unless included explicitly in FOR COLUMNS(...)`. |\n| analyze_sample_percentage  | 10.4.3                                                         | Percentage of rows from the table ANALYZE TABLE will sample to collect table statistics. Set to 0 to let MariaDB decide what percentage of rows to sample.                                                                                                                                                                                             |\n| histogram_type                         | 10.4.3-11.0                                                    | Specifies the type of histograms created by ANALYZE. Options are #SINGLE_PREC_HB,DOUBLE_PREC_HB or JSON_HB.                                                                                                                                                                                                                                       |\n| histogram_size                         | 10.7                                                           | Number of bytes or buckets (in case of JSON_HB) used for storing the histogram. If set to 0, no histograms are created by ANALYZE.]]                                                                                                                                                                                                                  |\n| log_slow_admin_statements | 11.0.1                                                         | Log slow OPTIMIZE, ANALYZE, ALTER, and other administrative statements to the slow log if it is open. Deprecated. Use log_slow_filter instead.                                                                                    |\n| log_slow_filter                      | (all versions)                                                 | Having an admin in the log_slow_filter will add slow ANALYZE_TABLE statements to the slow log.                                                                                                                                                                                                                                                      |\n| sort_buffer_size                    | (all versions)                                                 | For calculating the number of duplicates, ANALYZE TABLE uses a buffer of sort_buffer_size bytes per column. You can slightly increase the speed of ANALYZE TABLE by increasing this variable.                                    |\n\nExamples\n--------\n\n-- update all engine-independent statistics for all columns and indexes\nANALYZE TABLE tbl PERSISTENT FOR ALL;\n\n-- update specific columns and indexes:\nANALYZE TABLE tbl PERSISTENT FOR COLUMNS (col1,col2,...) INDEXES (idx1,idx2,...);\n\n-- empty lists are allowed:\nANALYZE TABLE tbl PERSISTENT FOR COLUMNS (col1,col2,...) INDEXES ();\nANALYZE TABLE tbl PERSISTENT FOR COLUMNS () INDEXES (idx1,idx2,...);\n\n-- the following will only update mysql.table_stats fields:\nANALYZE TABLE tbl PERSISTENT FOR COLUMNS () INDEXES ();\n\n-- when use_stat_tables is set to ''COMPLEMENTARY'' or ''PREFERABLY'', \n-- a simple ANALYZE TABLE  collects engine-independent statistics for all columns and indexes.\nSET SESSION use_stat_tables=''COMPLEMENTARY'';\nANALYZE TABLE tbl;\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/table-statements/analyze-table', '', 'https://mariadb.com/docs/server/reference/sql-statements/table-statements/analyze-table');
