Write an sql query to display whose name contain a
Answers
Answered by
4
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 it just gets translated to the following which is.
WHERE employee_name >= 'A' AND employee_name < 'C'
For all variants you would need to consider whether you want to include accented variants such as Á and test whether the queries above do what you want with these on your RDBMS and collation options.
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 it just gets translated to the following which is.
WHERE employee_name >= 'A' AND employee_name < 'C'
For all variants you would need to consider whether you want to include accented variants such as Á and test whether the queries above do what you want with these on your RDBMS and collation options.
Similar questions