Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2004
    Posts
    18

    Cool Unanswered: SQL Statement - INNER JOIN

    I have two tables:
    Employees[ID, FirstName, LastName]
    DLSUs[ID, Title, HeadID, DeputyHeadID, Link]

    I would like to be able to display
    (* DLSUs.Title (add its corresponding link)),
    (Employees.FirstName, Employees.LastName WHERE Emplooyees.ID = DLSUs.HeadID)
    (Employees.FirstName, Employees.LastName WHERE Emplooyees.ID = DLSUs.DeputyHeadID)

    The problem with this is that I'm trying to fill a table as it is built, using recordsets and "do loop". In other words I want to have all DLSUs to have there corresponding Title(with Link), Head and Deputy Head.

    This is what I have so far, it only prints out the first DLSU Title(with Link) with its Firstname, LastName. Should I be using INNER JOIN, I don't fully understand the principle of it.
    sqlStmt = "SELECT DLSUs.*, Employees.* FROM DLSUs, Employees WHERE DLSUs.DLSUType = 'LSU' AND Employees.ID = DLSUs.HeadID"

    < ...
    __do until objRS.EOF
    ____Response.Write "<tr><td width=""320"">"
    ____If NOT objRS("Link") = "" Then
    ______Response.Write "<a href=" & objRS("Link") & ">" & objRS("Title_EN") & "</a>"
    ____Else
    ______Response.Write objRS("Title_EN")
    ____End If
    ____Response.Write "</td>"
    ____Response.Write objRS("FirstName")
    ____Response.Write "</td></tr>"
    ____objRS.MoveNext
    __loop
    __objRS.close()
    ... >

    Thanks in advance for your help

    Gazzou
    Last edited by Gazzou; 06-09-04 at 11:46.

  2. #2
    Join Date
    Feb 2004
    Posts
    492
    How many rows are in your recordset after it is filled?

  3. #3
    Join Date
    Jan 2004
    Posts
    18
    I have about 40 DLSU's, some DLSU's can have only a Head and others can have both a Head and a Deputy Head. In the case where there is only a head, the field for Deputy Head is left empty. My code should read the content of the cell before creating the table. If the cell is empty do a normal table with one row, else do two rows, colspan etc.

Posting Permissions

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