Vidyalelo
MySQL · Q1025

MySQL

Programming · MySQL · question 1025

Q1025

Which statement is valid if '`sampledb`' is a database and '`tbl`' is a table in it?

A.
SELECT * FROM `sampledb.member`
B.
SELECT * FROM `sampledb`.`member`
Answer
C.
SELECT * FROM `member`.`sampledb`
D.
SELECT * FROM `member.sampledb`

Answer: Option B

Solution

Answer: Option B
Solution:
This question is asking about the correct way to reference a table within a database in MySQL.

In MySQL, you use the following format to access a table:

`database_name`.`table_name`

Let's break down each option:

Option A: `SELECT * FROM `sampledb.member`
This is incorrect because it uses the wrong format. The database name and table name should be separated by a dot (`.`).

Option B: `SELECT * FROM `sampledb`.`member`
This is the correct way to reference the table 'member' in the database 'sampledb'.

Option C: `SELECT * FROM `member`.`sampledb`
This is incorrect because it references the database name as the table name and the table name as the database name.

Option D: `SELECT * FROM `member.sampledb`
This is incorrect for the same reason as Option A, the database name and table name should be separated by a dot (`.`).

Therefore, the correct answer is Option B.