0

Hi, i have a problem while preparing to MySQL Developer Exam. Exactly i don't understand the question and the answer :)

So Test is here:

You work as database adminstrator for company inc.
You have written following statement:

SELECT 'Student Name'||stud_name
FROM students
WHERE stud_id=50;

Which of the following will be treated as a number literal in the SELECT statement?

A.50
B.stud_id
C.||
D.Student Name


The Table is:

CREATE TABLE students (
stud_id INT(3) NOT NULL,
stud_name VARCHAR(25) NOT NULL,
stud_phone INT(11) NOT NULL,
stud_adress VARCHAR(50) NOT NULL
)

The Insert is:

INSERT INTO students VALUES(50,'John',11111111,'New York');

1. The Main question is : What does "number literal" mean in the main question?---Which of the following will be treated as a number literal in the SELECT statement?

2. Why the query output is 0?

mysql> SELECT 'Student Name'||stud_name
-> FROM students
-> WHERE stud_id=50;
+---------------------------+
| 'Student Name'||stud_name |
+---------------------------+
| 0 |
+---------------------------+
1 row in set, 2 warnings (0.00 sec)

And it differs from query to query. Sometimes The output is 1 or "empty set"

mysql> SELECT 'Student Name'||stud_id
    -> FROM students
    -> WHERE stud_name='John';
Empty set (0.00 sec)
mysql> SELECT 'Student Name'||stud_id
    -> FROM students
    -> WHERE stud_phone=11111111;
+-------------------------+
| 'Student Name'||stud_id |
+-------------------------+
|                       1 |
+-------------------------+
1 row in set, 1 warning (0.00 sec)

3. The answer for test is C. it means that || is number literal in this select? :) why? :)

Thanks :)

2
Contributors
1
Reply
4
Views
5 Years
Discussion Span
Last Post by smantscheff
0

Must be a typo. ||, the OR operator, is by no means a number literal. It treats its operands as numbers, so one could argue that 'Student name' figures as a number literal here.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.