Reputation: 381
I have a Database like this"
NAME - AGE
alex - 20
mathew - 14
alexandra-31
human-10
now in a text box elsewhere when i type say "al",I should get the result as alex and alexandra.
how do i do this in MySQL? please help.
Upvotes: 1
Views: 60
Reputation: 58595
Select name, age
From yourtable
Where name like 'al%'
Or, if you want to type any part of the name:
Select name, age
From yourtable
Where name like '%le%'
Upvotes: 1
Reputation: 9853
create table your_table
(NAME varchar(50),AGE int);
insert into your_table (NAME,AGE) values ('alex',20);
insert into your_table (NAME,AGE) values ('mathew',14);
insert into your_table (NAME,AGE) values ('alexandra',31);
insert into your_table (NAME,AGE) values ('human',10);
select NAME from your_table where name like 'al%';
Should do the trick...
Upvotes: 0