File tree Expand file tree Collapse file tree 1 file changed +95
-0
lines changed Expand file tree Collapse file tree 1 file changed +95
-0
lines changed Original file line number Diff line number Diff line change @@ -173,10 +173,105 @@ Synonym for `LOWER()`.
173
173
174
174
Return the leftmost number of characters as specified.
175
175
176
+ * usage: LEFT(` str ` , ` len ` )
177
+ * len: length of character to return
178
+ * str: original string to extract characters
179
+ * if ` len ` is equal or less than 0, the function returns empty string
180
+ * function is multibyte safe.
181
+ * If any argument is ` NULL ` , the function returns ` NULL ` .
182
+
183
+ Examples:
184
+
185
+ ``` sql
186
+ SELECT LEFT(' ABCED' , 3 );
187
+ + -- ----------------+
188
+ | LEFT(' ABCED' , 3 ) |
189
+ + -- ----------------+
190
+ | ABC |
191
+ + -- ----------------+
192
+
193
+ SELECT LEFT(' ABCED' , 6 );
194
+ + -- ----------------+
195
+ | LEFT(' ABCED' , 6 ) |
196
+ + -- ----------------+
197
+ | ABCED |
198
+ + -- ----------------+
199
+ ```
200
+
201
+ ``` sql
202
+ SELECT LEFT(' ABCED' , 0 );
203
+ + -- ----------------+
204
+ | LEFT(' ABCED' , 0 ) |
205
+ + -- ----------------+
206
+ | |
207
+ + -- ----------------+
208
+
209
+ SELECT LEFT(' ABCED' , - 1 );
210
+ + -- -----------------+
211
+ | LEFT(' ABCED' , - 1 ) |
212
+ + -- -----------------+
213
+ | |
214
+ + -- -----------------+
215
+ ```
216
+
217
+ ``` sql
218
+ SELECT LEFT(' 🍣ABC' , 3 );
219
+ + -- ------------------+
220
+ | LEFT(' 🍣ABC' , 3 ) |
221
+ + -- ------------------+
222
+ | 🍣AB |
223
+ + -- ------------------+
224
+ ```
225
+
226
+ ``` sql
227
+ SELECT LEFT(' ABC' , NULL );
228
+ + -- -----------------+
229
+ | LEFT(' ABC' , NULL ) |
230
+ + -- -----------------+
231
+ | NULL |
232
+ + -- -----------------+
233
+
234
+ SELECT LEFT(NULL , 3 );
235
+ + -- ----------------------------+
236
+ | LEFT(NULL , 3 ) |
237
+ + -- ----------------------------+
238
+ | NULL |
239
+ + -- ----------------------------+
240
+ ```
241
+
176
242
### [ ` LENGTH() ` ] ( https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_length )
177
243
178
244
Return the length of a string in bytes.
179
245
246
+ * If any argument is ` NULL ` , the function returns ` NULL ` .
247
+
248
+ Examples:
249
+
250
+ ``` sql
251
+ SELECT LENGTH(' ABC' );
252
+ + -- -------------+
253
+ | LENGTH(' ABC' ) |
254
+ + -- -------------+
255
+ | 3 |
256
+ + -- -------------+
257
+
258
+ SELECT LENGTH(' 🍣ABC' );
259
+ + -- -----------------+
260
+ | LENGTH(' 🍣ABC' ) |
261
+ + -- -----------------+
262
+ | 7 |
263
+ + -- -----------------+
264
+ ```
265
+
266
+ ``` sql
267
+ SELECT LENGTH(NULL );
268
+ + -- ------------+
269
+ | LENGTH(NULL ) |
270
+ + -- ------------+
271
+ | NULL |
272
+ + -- ------------+
273
+ ```
274
+
180
275
### [ ` LIKE ` ] ( https://dev.mysql.com/doc/refman/8.0/en/string-comparison-functions.html#operator_like )
181
276
182
277
Simple pattern matching.
You can’t perform that action at this time.
0 commit comments