Wildcard character in SQL - Interview Questions for Placement
SELECT * FROM Employees WHERE Country LIKE '%a';
a) Return all the employees with the EmpName.
b) Return all the employees with an EmpName that starts with the letter a.
c) Return all the employees with an EmpName that ends with a letter a.
d) Return all the employee with an EmpName that contain the letter a.
Correct Answer: c - Return all the employees with an EmpName that ends with a letter a.
Explanation
‘ % ‘ is a wildcard character in SQL which represents zero or more characters. ‘ %a ‘ will find any values that ends with the letter a and does not care how long is the value as long as it ends with the letter a.
Discussion
- RE: Wildcard character in SQL - Interview Questions for Placement -Wildcard character (09/09/22)
- 1. SELECT ____ FROM Employees; will return all the columns from the Employees table.
a) @
b) #
c) *
d) $
Answer: c
‘ * ‘ is used along with SELECT statement in SQL, if we wish to select all the columns available in a table.
Example - SELECT * FROM Employees;
If you want to fetch the values of specific columns or fields of a table, then you have to specify column names such as
SELECT column1_name, column2_name, columnN_name FROM Employees; - RE: Wildcard character in SQL - Interview Questions for Placement -SQL (08/25/22)
- More questions required, please post more questions on Wildcard character