Mysql PHP,如何选择以特定carachter开头的数据

Alp*_*pha 2 php mysql

我有一张桌子cities:

+----+--------+
| id | zip    | 
+----+--------+
|  1 | 07500  | 
|  2 | 07501  | 
|  3 | 75000  | 
|  4 | 75001  | 
|  5 | 75002  | 
+----+--------+
Run Code Online (Sandbox Code Playgroud)

我需要选择field zip开头的数据750,所以我尝试过:

SELECT FROM cities WHERE ZIP LIKE '%750%'
Run Code Online (Sandbox Code Playgroud)

但这会返回包含的表中的所有数据750,这不正常.我怎么能告诉我的查询选择以750?开头的数据?

Vla*_*eda 10

执行此查询:

SELECT FROM cities WHERE ZIP LIKE '750%'
Run Code Online (Sandbox Code Playgroud)

说明

% 是一个特殊的MySQL字符,表示任何字符,空字符串或字符组.

例子:

LIKE '%a%' -- matches: a, ant, track | any string that contains a in any location
LIKE 'a%'  -- matches: a, ant        | strings that start with a
LIKE '%a'  -- matches: a, data       | strings that end with a
Run Code Online (Sandbox Code Playgroud)


Gue*_*rra 6

这应该是神奇的:

SELECT FROM cities WHERE ZIP LIKE '750%'
Run Code Online (Sandbox Code Playgroud)

开始时%表示之前的任何事情.