SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseSQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old March 4th, 2003, 08:39 AM
Lauren Lauren is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 2 Lauren User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
SQL to match 1 table's info with another table

<%<br> strconn = Server.MapPath("Coord_Login.mdb")<br> set conn=server.createobject("adodb.connection")<br> <br> conn.open "Provider = SQLOLEDB; data source = m308-srv;" _<br> & "Initial catalog = Coord_Login; user ID=gsi; password=gsi; " _<br> & "connect timeout = 30;"<br> <br> set rs = server.createobject("adodb.recordset")<br> rs.activeconnection = conn<br> <br> dim n<br> n=1<br> dim QueryString(0)<br> QueryString(0) = "IAP_Request.Sem=Student_info.sem"<br> 'QueryString(1) = "IAP_Request.Race=Student_info.race"<br> <br> SQL = "SELECT * FROM IAP_Request where Status='Approved'"<br> rs.Open SQL<br> Dim setWhere <br> Dim gotLastString,i<br> tempstr = "SELECT Student_info.Postal_code,Student_info.gender,Stude nt_info.Name,IAP_Request.Comp_name from Student_info,IAP_Request"<br> <br> <br>'do while not rs2.EOF <br> <br> do while not rs.EOF<br> Response.Write("Companies approved")<br> Response.Write(rs.Fields("Comp_name").value)<br> Response.Write("////")<br> <br> Response.Write(tempstr)<br> 'Response.Write("///")<br> 'Response.write(rs2.Fields(3))<br> <br> rs.MoveNext<br> Loop<br> <br> if not rs.EOF then<br> For i=0 to UBound(QueryString)<br> <font style="color:990000;">if (rs.Fields("Sem").value <> "Nil" and rs.fields("Sem")<>"" and setWhere=false) then<br> tempstr = tempstr & " WHERE " & QueryString(i)<br> setWhere = true<br> gotLastString = true<br> <br> <br> <br> elseif (rs.Fields("Sem").Value<>"Nil" and rs.fields("Sem")<>"" and gotLastString=true) then<br> tempstr = tempstr & " AND " & QueryString(i)<br> gotlaststring = true<br> end if<br> next</font> end if<br> set rs2 = server.createobject("adodb.recordset")<br> rs2.activeconnection=conn<br> rs2.Open tempstr<br> <br> do while rs2.eof <> true<br> 'for i=0 to rs2.Fields.Count-1<br> Response.Write(rs2.Fields(3).value)<br> 'Next<br> rs2.movenext<br> loop<br> <br> <br> rs.Close<br> set rs2=nothing<br> set rs=nothing<br> set conn=nothing<br> <br>%><br><br><font style="color:800080;">I think there's some problems with my SQL coz my 1st SQL is supposed to have only 3 members fitting the criteria so the 2nd SQL should only be processing 3 members but my 2nd SQL is not picking up just the 3 members from the 1st RS but processing all the members fitting the 2nd SQL,HELP!</font>

Reply With Quote
  #2  
Old July 8th, 2003, 02:15 AM
tsm tsm is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 1 tsm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi
you must use outer join, send me example with SQL
Tom

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseSQL Development > SQL to match 1 table's info with another table


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT