如何在MySQL中使用H搜索名称

如何在MySQL中使用H搜索名称

它应该很简单,但是不起作用

 SELECT * FROM profile WHERE name LIKE = 'H%';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= 'H%'' at line 1


表中的列

SHOW COLUMNS FROM profile;
+-------+-------------------------------------------------------------+------+-----+---------+----------------+
| Field | Type                                                        | Null | Key | Default | Extra          |
+-------+-------------------------------------------------------------+------+-----+---------+----------------+
| id    | int(10) unsigned                                            | NO   | PRI | NULL    | auto_increment |
| name  | varchar(20)                                                 | NO   |     | NULL    |                |
| birth | date                                                        | YES  |     | NULL    |                |
| color | enum('blue','red','green','brown','black','white')          | YES  |     | NULL    |                |
| foods | set('lutefisk','burrito','curry','eggroll','fadge','pizza') | YES  |     | NULL    |                |
| cats  | int(11)                                                     | YES  |     | NULL    |                |


我应该怎么做?

最佳答案

在您的选择语句中删除=
所以;

 SELECT * FROM profile WHERE name LIKE  'H%';

关于mysql - 如何在MySQL中使用H搜索名称?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/45344914/

10-12 17:25