[SQL] Query using Data from 2 Tables

  • Thread starter Thread starter WWGD
  • Start date Start date
  • Tags Tags
    Data Sql
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
4 replies · 2K views
Science Advisor
Homework Helper
Messages
7,842
Reaction score
13,164
Hi, say I am doing a query for which I need data from two tables,

on, say the salary of those who teach French from 2-to-3 P.M, and one table T_1

contains the teaching subject and another table T_2 contains the class schedule/hours.

Say these two tables are related.

Do we then do a query on the join of the tables T_1 with T_2 ?
 
Physics news on Phys.org
Yes you simply do a join.
It depends on which table may contain NULL values.
Lets say :

SELECT *
FROM T_1
LEFT JOIN T_2
ON T_1.subject = T_2.subject;

This query tells to join the left table (T_1) with the right table (T_2) . The result will be NULL on the right side if there is no match.
 
I see, thanks, but the join table is not actually created, is it, it just lives in memory when the query is being computed, right?
 
Sorry for the late reply,
Yes, the table won't be created
 
Thank you, ZLB.