Which two queries select only those rows?

You want to query the VARCHAR column ‘ code’ values that match:
• Start with “p”
• End with “_”
• Contain more than 3 characters
Assume that sql_mode is blank.
Which two queries select only those rows?

You want to query the VARCHAR column ‘ code’ values that match:
• Start with “p”
• End with “_”
• Contain more than 3 characters
Assume that sql_mode is blank.
Which two queries select only those rows?

A.
SELECT code FROM operations WHERE code LIKE “p&&_”;

B.
SELECT code FROM operations WHERE code LIKE “ ’&’&_’ “ESCAPE “ ‘ ’’;

C.
SELECT code FROM operations WHERE code LIKE “p&_\_”;

D.
SELECT code FROM operations WHERE code LIKE “p_\&\_”;

E.
SELECT code FROM operations WHERE code LIKE “p_7_&;_”ESCAPE “/”;



Leave a Reply 9

Your email address will not be published. Required fields are marked *


Zizo

Zizo

Correct answers are A and C but only if the ampersand was replaced by a percentage sign !

Jay

Jay

It is C and D.

set sql_mode=”;
create table operations
(
`code` varchar(10)
);

insert into operations values
(‘pat’),(‘pete’),(‘peterson’),
(‘tim’),(‘timothy’),(‘Jay’),
(‘pl%m’),(‘pl_m’),(‘ple%’),
(‘ple_’),(‘pl%_’),(‘ple_%’);

SELECT code FROM operations WHERE code LIKE “p%%_”; #A, has the ability to grab less than 4 letters#
SELECT code FROM operations WHERE code LIKE “|%|%_’” ESCAPE “|”; #B, can only grab the specific phrase of %%_ #
SELECT code FROM operations WHERE code LIKE “p%_\_”; #C, works#
SELECT code FROM operations WHERE code LIKE “p_\%\_”; #D, works#
SELECT code FROM operations WHERE code LIKE “p_7_&;_” ESCAPE “|”; #E, No Idea on what they are asking for#

Jay

Jay

Actually it isn’t C!

add this to the list:
insert into operations values (‘pa_’); #C, won’t work now#

It’s D and most likely E.

doris

doris

more than 3 characters…

Jay

Jay

E works if this is statement:
SELECT code FROM operations WHERE code LIKE “p_|_%|_” ESCAPE “|”; #E#
OR
SELECT code FROM operations WHERE code LIKE “p_%_%|_” ESCAPE “|”; #E#

and this to the table:
insert into operations values (‘pa__’),(‘pa_dfds_’);

zz

zz

SELECT code FROM operations WHERE code LIKE “p_%_%|_” escape “|”;
SELECT code FROM operations WHERE code LIKE “p%__\_”;

jcf

jcf

C+E
SELECT code FROM operations WHERE code LIKE ‘p%_\_’;
SELECT code FROM operations WHERE code LIKE ‘p_%_%;_’ESCAPE ‘/’;

pappu

pappu

D,E
wildcat “&” mean zero to many