~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to docs/functions/string/comparative.rst

  • Committer: Package Import Robot
  • Author(s): Dmitrijs Ledkovs
  • Date: 2013-10-29 15:43:40 UTC
  • mfrom: (1.2.12) (2.1.19 trusty-proposed)
  • Revision ID: package-import@ubuntu.com-20131029154340-2gp39el6cv8bwf2o
Tags: 1:7.2.3-2ubuntu1
* Merge from debian, remaining changes:
  - Link against boost_system because of boost_thread.
  - Add required libs to message/include.am
  - Add upstart job and adjust init script to be upstart compatible.
  - Disable -floop-parallelize-all due to gcc-4.8/4.9 compiler ICE
    http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57732

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
Comparative Functions
2
2
=====================
3
3
 
 
4
'TODO'
 
5
 
4
6
.. _like-function:
5
7
 
6
 
LIKE            
 
8
LIKE            
7
9
----
8
10
 
9
 
The LIKE operator is used to check if field values match a specified pattern, and searches for less-than-exact but similar values.
10
 
 
11
 
The LIKE operator supports the use of two wildcards. (Wildcards provide more flexibility by allowing any character or group of characters in a string to be acceptable as a match for another string):
12
 
 
13
 
    * Percentage (%): Represents zero or more values.
14
 
    * Underscore (_): Matches exactly one character value.
15
 
 
16
 
In accordance the SQL standard, LIKE performs matching on a per-character basis. It therefore provides results different from the = comparison operator.
17
 
 
18
 
The following SELECT statement includes a WHERE clause in order to search for job titles that start with "DIRECTOR", by using the percentage wildcard after the lookup value.
19
 
 
20
 
For example:
21
 
 
22
 
.. code-block:: mysql
23
 
 
24
 
        SELECT title, field
25
 
        FROM job_detail
26
 
        WHERE title LIKE 'DIRECTOR%'
27
 
        ORDER BY field, title;
 
11
 
 
12
 
28
13
 
29
14
.. _regex-function:
30
15
 
31
16
REGEX
32
17
-----
33
18
 
34
 
Undocumented.
35
19
 
36
20
.. _regexp-function:
37
21
 
38
22
REGEXP
39
23
------
40
24
 
41
 
Returns values that match a regular expression pattern; they are commonly used for creating complex searches. Here is an example of using a REGEXP (Regular Expression) match:
42
 
 
43
 
.. code-block:: mysql
44
 
 
45
 
        SELECT title, category_name
46
 
        FROM film_detail
47
 
        WHERE title REGEXP '^AIRP[LO]'
48
 
        ORDER BY title;
49
 
 
50
 
Other REGEXP examples:
51
 
 
52
 
.. code-block:: mysql
53
 
 
54
 
        SELECT 'abcabc' REGEXP 'abc',    
55
 
        'abcabc' REGEXP 'cb';
56
 
 
57
 
The search pattern may describe only a part of string. To match entire string, use ^ and $ in the search:
58
 
 
59
 
.. code-block:: mysql
60
 
 
61
 
        SELECT 'abc' REGEXP '^abc$', 'abcabc' REGEXP '^abc$';
62
 
 
63
 
        SELECT 'cde' REGEXP '[a-c]+', 'efg' REGEXP '[a-c]+';
64
 
 
65
 
        SELECT 'abcabc' REGEXP 'ABC', 'abcabc' REGEXP BINARY 'ABC';
 
25
 
66
26
 
67
27
.. _strcmp-function:
68
28
 
69
29
STRCMP
70
30
------
71
31
 
72
 
The purpose of STRCMP is also to compare two strings. This function returns 0 if two strings are the same, -1 if the first argument is smaller than the second according to the current sort order, and 1 otherwise.