i want to display the employee names which having names start with a and b ,it should be like list will display employees with 'a' as a first letter and then the 'b' as a first letter...
so any body tell me what is the command to display these...
i want to display the employee names which having names start with a and b ,it should be like list will display employees with 'a' as a first letter and then the 'b' as a first letter...
so any body tell me what is the command to display these...
select columns
from table
where (
column like 'a%'
or column like 'b%' )
order by column asc
To get employee names starting with A or B listed in order...
select employee_name
from employees
where employee_name LIKE 'A%' OR employee_name LIKE 'B%'
order by employee_name
If you are using Microsoft SQL Server you could use
....
where employee_name LIKE '[A-B]%'
order by employee_name
This is not standard SQL though.
What cfengineers said, except it sounds like you will want to sort it as well.
select columns
from table
where (
column like 'a%'
or column like 'b%' )
order by column
Perhaps it would be a good idea for you to check out some tutorials on SQL, it's pretty interesting.
If you're asking about alphabetical order the syntax is:
SELECT * FROM table ORDER BY column
the best example I can give without knowing your table and field names:
SELECT * FROM employees ORDER BY name
select * from stores where name like'a%' or name like 'b%' order by name
select name_last, name_first
from employees
where name_last like 'A%' or name_last like 'B%'
order by name_last, name_first asc