SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2002
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MySQL-help needed

    Hi!
    I have som problems finding the right sql-query for outputting data from a MySQL-db.

    Let's say I have 4 tables.I have 4 tables(actually there are more, but I think only four are of interest here):

    user: uid, username, firstname, lastname
    assignment: aid, filename, uid
    subject: sid, subjectname
    user_subject: uid, subject

    What I need is to list out all the users, those who have delivered an assignment should have the filename listed next to their name. Others will instead have the text 'no file'.

    I've tried alot, and this is what I've come up with, but it's not correct. I could use some help from others...

    Code:
     
    $sql = "SELECT DISTINCT user.firstname, user.lastname, IFNULL(assignment.filename, 'no file') AS filename
    	  FROM user 
    	  LEFT JOIN user_subject ON user.uid=user_subject.uid 
    	  LEFT JOIN assignment ON user_subject.uid=assignment.uid 
    	  WHERE user_subject.subjectname='english' 
    	  AND assignment.aid='1'"; 

  2. #2
    SitePoint Addict
    Join Date
    Mar 2002
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What does it do as it stands?

    Nick
    All4YourPC for all your PC needs. Custom software.
    Websites. Web marketing. Training.
    http://members.aol.com/nickjc67

  3. #3
    SitePoint Wizard silver trophy redemption's Avatar
    Join Date
    Sep 2001
    Location
    Singapore
    Posts
    5,269
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm this is a double post.

    Please follow up your comments here -> http://www.sitepointforums.com/showt...hreadid=106326 . Check out post #8.

    Thanks!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •