Last answered:

10 Mar 2023

Posted on:

09 Mar 2023

1

Resolved: SELECT statement works but why?

Hi 365-team,


I have two questions (please see my screenshot below): 

1. the select contains no semicolon at the end but the statement still works. I expected an error.

2. how does the "statement" know which database/schema to use? I expected to enter the command "USE employees" before.


1 answers ( 1 marked as helpful)
Instructor
Posted on:

10 Mar 2023

0

Hi Jan!
Thanks for reaching out.


1) The query still works, but if you have another query after this, an error 1064 will occur. So, it is best practice to use ; at the end of your query.

2) Actually, you have to double-click on the DB you want to work with, or use:

USE db_name;

otherwise an error 1046 will occur. In this particular case some default database may be set. But the database should be bolded. So, you can just double-click and select your database.


Hope this helps.
Best,
Tsvetelin

Submit an answer