CodeAve.com CodeAve.com - ASP - Database Table Display
ASP
·Read/Write
·Script Writers
·Database Display
·Response Objects
·Server Variables
·Random Events
·Articles
·Miscellaneous
·Contents
·What's New?
JavaScript
CSS
HTML
Maps
Links
Mail List
Search
Sitemap


 


Two Table Join
Outputting data from two tables is almost as easy as displaying from one. This example utilizes two tables with state information on them. The first table (state_order) contains state abbreviations (state), state names (statename) the year each state was admitted into the union (year) and the numeric order they entered in (entered) . The second table (state_capitals) contains state abbreviations (state), state names (state) and state capitals (capital). The where statement (state_order.state = state_capitals.state) looks to make a match on the field that each table has in common to ouput the correct capital with all the info from the state_order table.
View the Output
Text View
Print View
Mail this Link
Download the Code
View the Data

<%
accessdb="state_info" 
cn="DRIVER={Microsoft Access Driver (*.mdb)};"
cn=cn & "DBQ=" & server.mappath(accessdb)
Set rs = Server.CreateObject("ADODB.Recordset")


sql = "select state_order.*, state_capitals.capital"
sql = sql & " from state_order, state_capitals where state_order.state = state_capitals.state"
sql = sql & " order by entered; "

rs.Open sql, cn
%>


<%= sql %>
<p>
U.S. States in order admitted into the Union
</p><table>
<%
rs.MoveFirst
do while not rs.eof
%>

<tr>
<td>&nbsp;<%= rs("entered") %>&nbsp;</td>
<td>&nbsp;<%= rs("year") %>&nbsp;</td>
<td>&nbsp;<%= rs("statename") %>&nbsp;</td>
<td>&nbsp;<%= rs("capital") %>&nbsp;</td>
</tr>

<%
rs.movenext
loop%>
</table>

 

 

 



ASP: What's New? | Articles | Script Writers | Database Display | Read/Write
Server Variables | Response Objects | Random Events | Miscellaneous
HTML: Forms | Hyperlinks | Headers | Tables | Hyperlinks | Headers | Text Display
JavaScript: Document Info | Forms | Images | Navigation | Script Writers
CSS: Basics | Page Display | Text Display | Script Writers | Miscellaneous
  • 2014 michael kors
  • air max women 2013
  • 2014 michael kors
  • air max 2014
  • oakley glasses
  • oakley glasses

  • Maps: Map Script Writers | Bing Maps | Google Maps
  • bottes fr
  • ugg boot
  • Privacy Statement

    CodeAve.com is hosted by MyHosting.com
    Donate Food Online with a Mouse Click at TheHungerSite.com
    Donate Land Online with a Mouse Click at TheRainForestSite.com
    © 1999 - 2017 CodeAve.com
    All Rights Reserved

  • Kids jordan 6 rings
  • Jordan retro 10
  • Jordan retro 3