Write the SQL code required to list the employee number, last name, first name, and middle initial of all employees whose last names start with Smith. In other words, the rows for both Smith and Smithfield should be included in the listing. Sort the results by employee number. Assume case sensitivity.

Respuesta :

Answer:

The SQL Code to this question can be given as:

Assume that

employee number= EMP_NUMBER //employee number

last name=EMP_L_NAME //employee last name

first name=EMP_F_NAME //employee first name

middle initial=EMP_M_INITIAL //middle initial

employee =EMP //table name

Code:

SELECT EMP_NUMBER ,EMP_L_NAME,EMP_F_NAME,EMP_M_INITIAL

FROM EMP WHERE EMP_L_NAME LIKE '%Smith%'

ORDER BY EMP_NUMBER

Explanation:

In the above SQL(Structure Query Language). It is used to communicate to the database in the form of a query. In the database, there is a table that is an employee(EMP).In this table there are employee number(EMP_NUMBER), last name(EMP_L_NAME) ,first number(EMP_F_NAME) and middle initial(EMP_M_INITIAL) columns. In the above code firstly we use the select command. This command used to return a set of records from the table. This command is part of DML(Data Manipulation Language). In the select command, we select the column that's data we want. then we define the table name where data stored. Then we apply condition by using where clause in that clause we use (%) sign for search data and use the order by clause for show the data into the order of employee number(ascending order).