MYSQL Join/Query

Discussion in 'PHP' started by MichaelLewis, May 14, 2008.

  1. #1
    (Thanks for redirecting me if I'm in the wrong forum.)

    Can anyone tell me what's wrong with this code?
    It tells me there was no data for this request.

    $query = "SELECT t1.*, t2.Desc
    FROM assignments AS t1 INNER JOIN tasks AS t2
    ON t1.Task AND t2.TaskID
    WHERE Ref= $DBRef[$cntry]";

    All my code before and after it is correct because the following works fine when I substitute it for the above. It finds data with this code.

    $query = "SELECT * FROM assignments WHERE Ref= $DBRef[$cntry]";

    Thanks,
    Michael
     
    MichaelLewis, May 14, 2008 IP
  2. Technica

    Technica Active Member

    Messages:
    624
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #2
    Try this

    $query = "SELECT t1.*, t2.Desc
    FROM assignments AS t1 INNER JOIN tasks AS t2
    ON t1.TaskID = t2.TaskID
    WHERE Ref= $DBRef[$cntry]";


    Hope this helps
     
    Technica, May 14, 2008 IP