MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

SQL

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Which of these SQL statements will select all the members with last names that start with capital letter “M” in the table member?
A
select * from member where last ____ name="M%";
B
select * from member where last ____ name="M-”
C
Select * from member where last ____ name="M”
D
select * from member where last ____ name like “M%”
Explanation: 

Detailed explanation-1: -With SQL, how do you select all the records from a table named “Persons” where the “LastName” is alphabetically between (and including) “Hansen” and “Pettersen"? SELECT * FROM Persons WHERE LastName BETWEEN ‘Hansen’ AND ‘Pettersen’;

Detailed explanation-2: -SELECT left(NAME, charindex(’ ‘, NAME)-1) AS ‘FirstName’, REVERSE(SUBSTRING(REVERSE(NAME), 1, CHARINDEX(’ ‘, REVERSE(NAME))-1)) AS ‘LastName’ FROM TABLE Error: Invalid length parameter passed to the LEFT or SUBSTRING function.

Detailed explanation-3: -With SQL, how do you select all the records from a table named “Persons” where the value of the column “FirstName” ends with an “a”? Explanation: The SQL LIKE clause is used to compare a value to similar values using wildcard operators.

Detailed explanation-4: -SELECT * FROM <TableName>; This SQL query will select all columns and all rows from the table. For example: SELECT * FROM [Person].

There is 1 question to complete.