MishaVacic MishaVacic - 1 year ago 57
MySQL Question

How do I search for names with H in MySQL?

It should be simple but it is not working

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


Columns from table

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 | |


What should I try?

Answer Source

remove = in your select statement so;

 SELECT * FROM profile WHERE name LIKE  'H%';
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download