Condition types

Equality Conditions

Equality Conditions

$field = $value

Inequality Conditions

$field <> $value

Range Conditions

<, >, >=, <=

BETWEEN $lower AND $upper (包含上下限)

WHERE rental_data BETWEEN '2005-06-14' AND '2005-06-16';

String ranges

FROM customer WHERE last_name BETWEEN 'FA' AND 'FR' 并不包含以'FR'开头的字符串,因为,'FRA'在'FR'之后

因此可以使用BETWEEN 'FA' AND 'FRZZ' 提取所有以'FA'到'FR'开头的字符串

Membership Conditions

$field = $value1 OR $filed = $value2 等同于 $field IN ($value1, $value2)

using subqueries

SELECT title, rating
FROM film
WHERE rating IN (SELECT rating FROM file WHERE title LIKE '%PET%');

not in not like

Matching Conditions

left($string, $index)

wildcards

_ %

Wildcard character Matches
_ Exactly one character
% Any Number of character (including 0)

regular expressions

WHERE $field REGEXP '$regex'

'\\w' Butnot \w !!!!!

null 判断: IS NULL

results matching ""

    No results matching ""