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 October 29th, 2003, 03:54 AM
jmontfort jmontfort is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 8 jmontfort User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Advanced SQL Problem

Dear All,

I have 2 retreive some data from 2 tables that are linked together, however I cannot manage to do it.

My first table has three fields that are relevant to me and these are NAME,USERPASS and ACCOUNT, and the second table has CODE and EMAIL. ACCOUNT from the first table and CODE from the second table are linked together.

Now what I want to do is retreive the NAME AND USERPASS from the first table where the ACCOUNT is the same as the CODE and then send out an e-mail with the username and password.

I tried this query, however it is not working:-

SELECT XERSITES.ACCOUNT, STKCST.CODE, XERSITES.NAME, XERSITES.USERPASS, STKCST.EMAIL
FROM XERSITES INNER JOIN STKCST ON XERSITES.ACCOUNT = STKCST.CODE;

Can you please help me out?

Thanks for your time

Reply With Quote
  #2  
Old October 29th, 2003, 04:21 AM
jmontfort jmontfort is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 8 jmontfort User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Ok i have discovered that I cannot use an inner join since the driver does not support it! I have to do a nested loop

Reply With Quote
  #3  
Old October 29th, 2003, 05:15 AM
jmontfort jmontfort is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 8 jmontfort User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I have come up with this code:-

Set rsSelect=Server.CreateObject("ADODB.Recordset")
rsSelect.ActiveConnection = cnnDFlex

Set rsSelectSTK=Server.CreateObject("ADODB.Recordset")
rsSelectSTK.ActiveConnection = cnnDFlex

sqlSelect="SELECT name, userpass, account FROM xersites WHERE EMAIL <> ''"
rsSelect.Open (sqlSelect)
rsSelect.movefirst
do
sqlSelectSTK="SELECT code, email FROM stkcst WHERE EMAIL <> ''"
rsSelectSTK.Open (sqlSelectSTK)
rsSelectSTK.movefirst
do
if rsSelect("account") = rsSelectSTK("code") then
sqlInsertIntoTemp="insert into temp(name,userpass,email) values(" & rsSelect("Name") & ",'" & rsSelect("userpass") & "','" & rsSelectSTK("Email") & "')"
set rsInsertIntoTemp=cnnDFlex.execute(sqlInsertIntoTem p)
rsSelectSTK.movenext
loop until rsSelectSTK.eof
end if
rsSelect.movenext
loop until rsSelect.eof

but it is giving me an error:-

Error Type:
Microsoft VBScript compilation (0x800A040E)
'loop' without 'do'
/isl/admin/createtemptable.asp, line 42
loop until rsSelectSTK.eof


Please can you help me out?

Reply With Quote
  #4  
Old October 29th, 2003, 12:41 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 22 h 33 m
Reputation Power: 181
Count up your "do" statements and "loop" statements, I think you are short one loop

Reply With Quote
  #5  
Old October 30th, 2003, 03:27 AM
jmontfort jmontfort is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 8 jmontfort User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Ok I went for another approach and it did work:-

Set rsSelect=Server.CreateObject("ADODB.Recordset")
rsSelect.ActiveConnection = cnnDFlex
'sqlSelect="SELECT * FROM xersites WHERE EMAIL <> ''"
sqlSelect="SELECT DISTINCT STKCST.CODE, XERSITES.ACCOUNT, XERSITES.NAME, XERSITES.USERPASS, STKCST.EMAIL"
sqlSelect = sqlselect & " FROM XERSITES, STKCST WHERE XERSITES.ACCOUNT = STKCST.CODE"
'sqlSelect = sqlselect & " AND STKCST.EMAIL = 'jmontfort@hotmail.com'"
sqlSelect = sqlSelect & " AND STKCST.EMAIL <> ''"
rsSelect.Open (sqlSelect)

Thanks for your help

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseSQL Development > Advanced SQL Problem


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


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





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