View the Exhibit and examine the structure of the PRODUCTS table.
You need to generate a report in the following format:
CATEGORIES
5MP Digital Photo Camera’s category is Photo
Y Box’s category is Electronics
Envoy Ambassador’s category is Hardware
Which two queries would give the required output? (Choose two.)
A.
SELECT prod_name q”’s category is ‘ prod_category CATEGORIES FROM products;
B.
SELECT prod_name q'[‘s ]’category is ‘ prod_category CATEGORIES FROM products;
C.
SELECT prod_name q’\’s\’ ‘ category is ‘ prod_category CATEGORIES FROM products;
D.
SELECT prod_name q'<‘s >’ ‘category is ‘ prod_category CATEGORIES FROM products;
C. SELECT prod_name || q’\’s\’ || ‘ category is ‘ || prod_category CATEGORIES FROM products;
D. SELECT prod_name || q” || ‘category is ‘ || prod_category CATEGORIES FROM products;
Updated answers.
Hi, please tell me why B is incorrect?
B is incorrect because concatenation is missing between q'[‘s]’ and text ‘category is’. See my another update for the correct select statement.
To have correct statement:
SELECT prod_name||q'[‘s ]’||’ category is’||’ prod_category CATEGORIES FROM products;
or
SELECT prod_name||q'[‘s category is]’||’ prod_category CATEGORIES FROM products;
What’s different between symbol ‘ and symbol ’?
And I tried this pattern on this statement, but it failed on oracle 11g.
SELECT ENAME||q'[‘s ]’||’ category is’||’ SAL CATEGORIES FROM EMP;
I did not notice eariler but there is missing single quotation mark ‘ after prod_category in each statement.
SELECT prod_name||q'[‘s ]’||’ category is’||’prod_category’ CATEGORIES FROM products.
Each quotation mark is the same. It is ‘. Something happend when I copied statements.
A.SELECT prod_name||q”’s category is||‘ prod_category CATEGORIES FROM products;
B. SELECT prod_name||q’[‘s ]‘category is||‘ prod_category CATEGORIES FROM products;
C. the same like above:
SELECT prod_name||q’\’s\’||‘ category is ‘||prod_category CATEGORIES FROM products;
D.SELECT prod_name||q’’||‘category is||‘ prod_category CATEGORIES FROM products;
Why is A incorrect?
what is the role of ‘q’ in the query?
Q or q indicates that the alternative quoting mechanism will be used
check http://stackoverflow.com/questions/11315340/pl-sql-how-to-escape-single-quote-in-a-string
A is incorrect because the expression should be without “q”
select prod_name||”’s category is ‘||prod_category CATEGORIES from products;
just to add on option a could also be
select prod_name||q”’s category is ”||prod_category CATEGORIES from products;
Why are the pipes || omitted from the queries???