View Items from another Table

Results 1 to 3 of 3

Thread: View Items from another Table

  1. #1
    Join Date
    Dec 1969

    Default View Items from another Table

    I want to Display the EmployeeName instead of their EmployeeID<BR>The name is held in another table. Here is what I&#039;m trying<BR><BR>SQL = "select * from Employees Where EmployeeID="+ rs(EmployeeID)<BR>Set rt = Conn.Execute(Sql) <BR><BR>Then <BR><BR>response.write FillEmpty(rt(EmployeeName))<BR>Instead of<BR>response.write FillEmpty(rs(EmployeeID))<BR><BR>But the &#039; Where EmployeeID="+rs(EmployeeID) &#039; is causeing an error, if i make it<BR>&#039; Where EmployeeID=1" &#039; then it works, but only shows the name of EmployeeID(1)<BR><BR>what am I doing wrong?<BR>

  2. #2
    Join Date
    Dec 1969

    Default Learn to use a JOIN

    You never never never want to open multiple nested recordsets unless there is simply no other way.<BR><BR>YOu need to learn how to do simple JOINs in SQL.<BR><BR>In this case:<BR><BR>SELECT table1.*, Employees.EmployeeName<BR>FROM table1, Employees<BR>WHERE Employees.EmployeeID = table1.EmployeeID<BR><BR>[Changing "table1" to the actual name of your other table, of course.]<BR><BR>

  3. #3
    Join Date
    Dec 1969

    Default agreed... JOINS are fun

    I used to be in the same boat as you. Now I&#039;m on the Luxury Cruiseship of Efficiency. Listen to that Bill guy.<BR><BR>BTW: Your problem lies in the +rs(EmployeeID). it should read:<BR>&rs("EmployeeID")<BR>just a simple syntax error. You need a "&" sign instead of a "+", and quotes around your fieldname.<BR><BR>~~Chaotix

Posting Permissions

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