Morpheusweb.it - Risorse per webmaster: script, ASP.NET, C#, Visual Basic .Net, tutorial, asp, javascript, css, php, html, java, ADO, VBScript, forms, frames, Active Server Pages, Dynamic HTML, database, gratis per webmaster e webdesigner

Union

To join the result of query on more tables.


<%
Dim cn,cm
Set cn = Server.CreateObject("ADODB.Connection")
cn.Open "driver={Microsoft Access Driver (*.mdb)};dbq="& Server.MapPath("Archive.mdb")
set rs=cn.execute ("Select * from [table] union Select * from [second table]")
while not rs.eof
response.write rs(0)&"<br>"
rs.movenext
wend
cn.close
Set cn = NOTHING
Set rs = Nothing
%>

The tables must have the same number of fields, or we need to specify an equal number of field in the select.

set rs=cn.execute ("Select nome,eta from [table] union Select name,age from [second table]")

To read values, we must use positional notation:

<%
name=rs(0)
age=rs(1)
%>


Download code...


Print this page


 

Inizio pagina

risorse per webmaster