Reputation: 37
I have a very difficult task for me. I don't understand, which query I should write to display needed dates. So, the task is to join different tables in one temporary table. I have tables
So I want to get the patient's full name, his address, dob (date of birthday), his gender, user's full name, status's name and diagnosis How to do it? Can you attach the link with the theory ?
Upvotes: 0
Views: 45
Reputation: 351
I assume dob
and gender
refer to patient dob and gender.
SELECT task.ID, task.diagnosis, patient.name, patient.surname, patient.m_name, user.name, user.surname, user.m_name, status.name, patient.address, patient.dob, patient.gender
FROM task
INNER JOIN user ON task.id_user=user.ID
INNER JOIN patient ON task.id_patient = patient.ID
INNER JOIN status ON task.id_status = status.ID
Here is an example how to use INNER JOIN.
You can read more here: JOIN Syntax
Upvotes: 0
Reputation: 1055
Here's an Example:
CREATE TEMPORARY TABLE IF NOT EXISTS table2 AS (
SELECT column_name(s)
FROM table1
INNER JOIN table2 ON table1.column_name = table2.column_name
....
)
About Inner Join: Link
Creating a Temporary Table :Link
Upvotes: 1