Solved

Dreamweaver ASP and MSSQL---  multiple query problem

Posted on 2004-09-01
3
387 Views
Last Modified: 2012-06-21
When I run the following query in  the Query Analyzer I get correct values

SELECT dbo.tutee.idratuteeid,dbo.tutee.firstname,dbo.tutee.lastname,dbo.tutee.mi,dbo.tutee.gradelevel,dbo.tutee.room,dbo.tutee.elemteacherid,dbo.elemteacher.elemteacherid,dbo.elemteacher.firstname,dbo.elemteacher.lastname
FROM dbo.tutee, dbo.elemteacher
WHERE dbo.elemteacher.elemteacherid=dbo.tutee.elemteacherid

 AND dbo.tutee.teachercoordid =101


When Dreamweaver's ASP repeated regions behavior codes it like this..

          <td><%=(Recordset1.Fields.Item("idratuteeid").Value)%></td>
          <td><%=(Recordset1.Fields.Item("firstname").Value)%></td>
          <td><%=(Recordset1.Fields.Item("lastname").Value)%></td>
          <td><%=(Recordset1.Fields.Item("mi").Value)%></td>
          <td><%=(Recordset1.Fields.Item("gradelevel").Value)%></td>
          <td><%=(Recordset1.Fields.Item("room").Value)%></td>
          <td><%=(Recordset1.Fields.Item("elemteacherid").Value)%></td>
          <td><%=(Recordset1.Fields.Item("elemteacherid").Value)%></td>
          <td><%=(Recordset1.Fields.Item("firstname").Value)%></td>
          <td><%=(Recordset1.Fields.Item("lastname").Value)%></td>

The firstname and lastname values come from the same table which is BAD!!!
What can I add to the Dreamweaver ASP code  to call from the correct tables.
Since I am a dumb dumb...I tried
          <td><%=(Recordset1.Fields.Item("dbo.elemteacher.lastname").Value)%></td>

and got a an error.

Obviously one of the problems is that the column names in the separate tables are the same...firstname, lastname...
1. Should I have named the differently?
2.  Is there a way for Dreamwever's ASP to differentiate between dbo.elemteacher.lastname and dbo.tutee.lastname

Thanks
0
Comment
Question by:hbojorquezgeek
  • 2
3 Comments
 
LVL 17

Accepted Solution

by:
BillAn1 earned 125 total points
ID: 11954903
you need to give the cols distinct aliases in the SQL , then you can refere to them properly in your ASP by their aliases :

SELECT
          dbo.tutee.idratuteeid AS idratuteeid,
      dbo.tutee.firstname AS tutee_fisttname,
      dbo.tutee.lastname AS tutee_lastname,
      dbo.tutee.mi as tutee_mi,
      dbo.tutee.gradelevel as gradelevel,
      dbo.tutee.room as room,
      dbo.tutee.elemteacherid as tutee_elemteacherid,
      dbo.elemteacher.elemteacherid as teacher_elemteacherid,
      dbo.elemteacher.firstname as teacher_firstname,
      dbo.elemteacher.lastname as teacher_lastname
FROM dbo.tutee, dbo.elemteacher
WHERE dbo.elemteacher.elemteacherid=dbo.tutee.elemteacherid
 AND dbo.tutee.teachercoordid =101
0
 

Author Comment

by:hbojorquezgeek
ID: 11955100
First...if I could I would bear your children!!!
Thank you...I am an obvious beginner at SQL and had no idea that I could do that... I've learned so much from this place about triggers and etc...THANKS!
You so rock.
0
 
LVL 17

Expert Comment

by:BillAn1
ID: 11955189
thanks I'm sure ?!
just don't forget to close out on a Question if you have the answer :-)
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating and Managing Databases with phpMyAdmin in cPanel.
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question