Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

[SQL] Query using Data from 2 Tables

  1. Mar 26, 2015 #1

    WWGD

    User Avatar
    Science Advisor
    Gold Member

    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 ?
     
  2. jcsd
  3. Mar 26, 2015 #2
    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.
     
  4. Mar 27, 2015 #3

    WWGD

    User Avatar
    Science Advisor
    Gold Member

    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?
     
  5. Mar 31, 2015 #4
    Sorry for the late reply,
    Yes, the table wont be created
     
  6. Mar 31, 2015 #5

    WWGD

    User Avatar
    Science Advisor
    Gold Member

    Thank you, ZLB.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: [SQL] Query using Data from 2 Tables
  1. I need a SQL query (Replies: 3)

  2. Use a data base or not (Replies: 3)

  3. Need Help on SQL query (Replies: 3)

Loading...