#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2012
    Posts
    1
    Rep Power
    0

    Sql Query any help would be appreciated please!


    IVe got two tables

    Comments
    Branch

    comments is like
    id userid branchid comments datetime
    1 3 4 blah 2012/01/03 00:00:00

    Branch like

    id branchName
    4 Argyle

    i need all branch id's and branch names from the branch table where the datetime in the comments table is a certain date like yesterday the problem is if there is no comment for a certain day it must still display the sales as null and any other comments that might have been writen for that day eg:

    id branchName sales
    1 Hosp 300
    2 RiverS NULL
    3 Lenv 250
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2003
    Location
    Paris Uppland
    Posts
    2,377
    Rep Power
    391
    Code:
    select Branch.branchName,
           Comments.comment
      from Branch
      left
      join Comments
        on Branch.id = Comments.BranchId
       and <yourDateCondition>

IMN logo majestic logo threadwatch logo seochat tools logo