Skip to content
Advertisement

SQL Searching not working form a particular starting element only ‘a’ and ‘e’

This is my code

SELECT * FROM `contacts` WHERE name = 'a%' AND name = 'e%';

but I’m getting error

so, how to display records in the table which is starting from a and e?

This is my error:- #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''a%' LIMIT 0, 25' at line 1

this is my table structure:- https://prnt.sc/ua0zvb

so, please help me…

Advertisement

Answer

Use like operator

SELECT * FROM `contacts` WHERE name like 'a%' or name  like 'e%'
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement