| --- |
| { |
| "title": "ARRAY", |
| "language": "en" |
| } |
| --- |
| |
| <!-- |
| Licensed to the Apache Software Foundation (ASF) under one |
| or more contributor license agreements. See the NOTICE file |
| distributed with this work for additional information |
| regarding copyright ownership. The ASF licenses this file |
| to you under the Apache License, Version 2.0 (the |
| "License"); you may not use this file except in compliance |
| with the License. You may obtain a copy of the License at |
| http://www.apache.org/licenses/LICENSE-2.0 |
| Unless required by applicable law or agreed to in writing, |
| software distributed under the License is distributed on an |
| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| KIND, either express or implied. See the License for the |
| specific language governing permissions and limitations |
| under the License. |
| --> |
| |
| ## array() |
| array() |
| ### description |
| |
| #### Syntax |
| |
| `ARRAY<T> array(T, ...)` |
| |
| construct an array with variadic elements and return it, T could be column or literal |
| |
| ### example |
| |
| ``` |
| mysql> select array("1", 2, 1.1); |
| +----------------------+ |
| | array('1', 2, '1.1') | |
| +----------------------+ |
| | ['1', '2', '1.1'] | |
| +----------------------+ |
| 1 row in set (0.00 sec) |
| |
| |
| mysql> select array(null, 1); |
| +----------------+ |
| | array(NULL, 1) | |
| +----------------+ |
| | [NULL, 1] | |
| +----------------+ |
| 1 row in set (0.00 sec) |
| |
| mysql> select array(1, 2, 3); |
| +----------------+ |
| | array(1, 2, 3) | |
| +----------------+ |
| | [1, 2, 3] | |
| +----------------+ |
| 1 row in set (0.00 sec) |
| |
| mysql> select array(qid, creationDate, null) from nested limit 4; |
| +------------------------------------+ |
| | array(`qid`, `creationDate`, NULL) | |
| +------------------------------------+ |
| | [1000038, 20090616074056, NULL] | |
| | [1000069, 20090616075005, NULL] | |
| | [1000130, 20090616080918, NULL] | |
| | [1000145, 20090616081545, NULL] | |
| +------------------------------------+ |
| 4 rows in set (0.01 sec) |
| ``` |
| |
| ### keywords |
| |
| ARRAY,ARRAY,CONSTRUCTOR |
| |