Johanna
Johanna

Reputation: 27640

How do I search for names starting wih A in MySQL?

I have a question that how can we use SELECT for searching the name which start with 'A' in MySQL table? thanks

Upvotes: 8

Views: 37214

Answers (6)

stepanian
stepanian

Reputation: 11433

SELECT * FROM table_name WHERE columnname LIKE 'A%'

Upvotes: 18

T.J. Crowder
T.J. Crowder

Reputation: 1074365

Using the LIKE operator, e.g.:

SELECT lastName FROM yourTable WHERE lastName LIKE 'A%'

Upvotes: 5

Charles Beattie
Charles Beattie

Reputation: 5949

http://www.w3schools.com/SQl/sql_wildcards.asp

SELECT * FROM Persons
WHERE Name LIKE 'A%'

Upvotes: 2

Oli
Oli

Reputation: 239820

You use the LIKE command. The % is a wildcard.

SELECT * FROM table WHERE column like 'A%';

Upvotes: 2

tangens
tangens

Reputation: 39733

SELECT name FROM <tablename> WHERE name like "A%"

Upvotes: 2

Bozho
Bozho

Reputation: 597106

MySQL docs

... LIKE 'A%'

(the first part of the query should be easy for you)

Upvotes: 6

Related Questions