How to avoid to write schema name before SELECT in mysql?

Viewed 938

I got a problem when joining the tables together. Please see my query below.

Practice is a schema that I have to write it every time when I fetch the table data. Is anybody can help me to not write the Schema name - Practice? Or is there any solution to the problem?

(the code below doesn't work because of unknown Practice.Worker.FIRST_NAME)

SELECT Practice.Worker.FIRST_NAME, Practice.Title.WORKER_TITLE
FROM Practice.Worker AS W INNER JOIN Practice.Title AS T
ON W.WORKEER_ID = T.WORKER_REF_ID;

Thanks!

1 Answers

Not sure what the exact problem is, but this is fairly simple:

SELECT W.FIRST_NAME, W.WORKER_TITLE
FROM Practice.Worker AS W
INNER JOIN Practice.Title AS T
ON W.WORKEER_ID = T.WORKER_REF_ID;

Alternatively, if you make Practice the default database, then you don't even need to type it, as in:

Use Practice;

SELECT W.FIRST_NAME, W.WORKER_TITLE
FROM Worker AS W
INNER JOIN Title AS T
ON W.WORKEER_ID = T.WORKER_REF_ID;
Related