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 al开发者_如何学Cex and alexandra.
how do i do this in MySQL? please help.
select *
from tableName
where name like 'al%'
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%'
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...
精彩评论