Examveda

Which of the following MySQL statements is valid if '`sampledb`' is a database and '`tbl`' is a table in it?

A. SELECT * FROM `sampledb.member`

B. SELECT * FROM `sampledb`.`member`

C. SELECT * FROM `member`.`sampledb`

D. SELECT * FROM `member.sampledb`

Answer: Option B

Solution (By Examveda Team)

This question is about how to correctly reference a table within a database in MySQL. Imagine you have a bookshelf (`sampledb`) and a book (`tbl`) on it. We need to tell MySQL where to find that book.

Let's look at each option:
Option A: SELECT * FROM `sampledb.member` - This is incorrect. The format is confusing and MySQL won't understand where to find the `member` table.
Option B: SELECT * FROM `sampledb`.`member` - This is the correct way to reference the table. It tells MySQL to look for the `member` table inside the `sampledb` database.
Option C: SELECT * FROM `member`.`sampledb` - This is wrong. It's like putting the book name first and then the bookshelf name, which doesn't make sense.
Option D: SELECT * FROM `member.sampledb` - Similar to Option A, this format is also incorrect. MySQL won't understand this reference.

Therefore, the only valid statement is Option B: SELECT * FROM `sampledb`.`member`.

This Question Belongs to MySQL >> MySQL Miscellaneous

Join The Discussion

Related Questions on MySQL Miscellaneous