The second query uses regex operator and it lists rows where id has 000 anywhere in it. So it's equivalent to: select id from tab where id '000' which lists only those id 's where id is 000. (regular expression match) is powerful but more. It compares the given value with the specified regular expression and gives the result accordingly. asked at 14:26 user494841 133 1 1 5 Add a comment 3 Answers Sorted by: 14 Your first query uses like operator but does not use any wildcards. LIKE ( ) is simple and fast but limited in its capabilities. Introduction to REGEXPLIKE () Function As discussed earlier, the REGEXPLIKE () function is used for pattern matching operations. See Regular Expressions Overview for details on the syntax for regular expressions (see also PCRE Regular Expressions ). The pattern can be an extended regular expression. Carlos Soublette #8-35Ĭarrera 52 con Ave. MySQL provides us with the REGEXPLIKE () function to use the regular expression to match it with the given attribute. To demonstrate how extended regular expressions work, the LIKE queries shown previously are rewritten here to use REGEXP. Syntax expr REGEXP pat, expr RLIKE pat Description Performs a pattern match of a string expression expr against a pattern pat. MySQL Examples MySQL Examples MySQL Editor MySQL Quiz MySQL Exercises MySQL CertificateĬarrera 22 con Ave. SQL LIKE queries You can use the same technique to make your SQL LIKE queries case insensitive as well. String Functions ASCII CHAR_LENGTH CHARACTER_LENGTH CONCAT CONCAT_WS FIELD FIND_IN_SET FORMAT INSERT INSTR LCASE LEFT LENGTH LOCATE LOWER LPAD LTRIM MID POSITION REPEAT REPLACE REVERSE RIGHT RPAD RTRIM SPACE STRCMP SUBSTR SUBSTRING SUBSTRING_INDEX TRIM UCASE UPPER Numeric Functions ABS ACOS ASIN ATAN ATAN2 AVG CEIL CEILING COS COT COUNT DEGREES DIV EXP FLOOR GREATEST LEAST LN LOG LOG10 LOG2 MAX MIN MOD PI POW POWER RADIANS RAND ROUND SIGN SIN SQRT SUM TAN TRUNCATE Date Functions ADDDATE ADDTIME CURDATE CURRENT_DATE CURRENT_TIME CURRENT_TIMESTAMP CURTIME DATE DATEDIFF DATE_ADD DATE_FORMAT DATE_SUB DAY DAYNAME DAYOFMONTH DAYOFWEEK DAYOFYEAR EXTRACT FROM_DAYS HOUR LAST_DAY LOCALTIME LOCALTIMESTAMP MAKEDATE MAKETIME MICROSECOND MINUTE MONTH MONTHNAME NOW PERIOD_ADD PERIOD_DIFF QUARTER SECOND SEC_TO_TIME STR_TO_DATE SUBDATE SUBTIME SYSDATE TIME TIME_FORMAT TIME_TO_SEC TIMEDIFF TIMESTAMP TO_DAYS WEEK WEEKDAY WEEKOFYEAR YEAR YEARWEEK Advanced Functions BIN BINARY CASE CAST COALESCE CONNECTION_ID CONV CONVERT CURRENT_USER DATABASE IF IFNULL ISNULL LAST_INSERT_ID NULLIF SESSION_USER SYSTEM_USER USER VERSION
0 Comments
Leave a Reply. |