[SQL] Query using Data from 2 Tables

  • Thread starter Thread starter WWGD
  • Start date Start date
  • Tags Tags
    Data Sql
AI Thread Summary
To retrieve salary data for teachers of French during the 2-to-3 PM time slot, a join query between two related tables, T_1 (which contains teaching subjects) and T_2 (which contains class schedules), is necessary. A LEFT JOIN is suggested, allowing for the inclusion of all records from T_1 and matching records from T_2, with NULL values appearing for unmatched records. It is clarified that the joined table is not physically created; instead, it exists temporarily in memory during query execution.
WWGD
Science Advisor
Homework Helper
Messages
7,679
Reaction score
12,489
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 ?
 
Technology 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.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...
Back
Top