[SQL] Query using Data from 2 Tables

  • Thread starter Thread starter WWGD
  • Start date Start date
  • Tags Tags
    Data Sql
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
4 replies · 2K views
Messages
7,819
Reaction score
13,151
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.
 
Sorry for the late reply,
Yes, the table won't be created