ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

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 Dev Shed Forums Sponsor:
  #1  
Old September 1st, 2003, 09:58 AM
benseri benseri is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Israel
Posts: 102 benseri User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via ICQ to benseri
Selecting Multiple Tables Using SELECT Statment problem

I am Trying to use the SQL SELECT Statment to open records from multiple tables into one recordset.

I know the basic syntax of the Select statment but I wanted to know if its possible to recive the table name from the feild or the record that I am readinf from the recordset in any given moment.

To make things more clear, my example:

-Open a connection

SQL = "SELECT * FROM TABLE1,TABLE2 WHERE TABLE1.UserID=" & uid & " And TABLE2.UserID=" & uid

rs.open sql,conn,3,3

while not rs.EOF

-read from record

rs.movenext
wend
rs.close
conn.close


now, in the part that I read from the record, is their any way I can know if that record is from table1 or table2?

thanks, Ben.


P.S. vlince, I looked a bit in google so u don't have to send me a link unless I am way of the topic I'm looking for...

Reply With Quote
  #2  
Old September 1st, 2003, 10:25 AM
unatratnag unatratnag is offline
Average Intelligence
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2003
Location: Ohio/Chicago
Posts: 678 unatratnag User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 22 sec
Reputation Power: 6
Send a message via AIM to unatratnag
absolutely, but you'll have to change your SQL statement to
Code:
SQL = "SELECT TABLE1.UserID as UID1, TABLE2.UserID as UID2, etc....
 "FROM TABLE1,TABLE2 " & _
"WHERE TABLE1.UserID=" & uid & _ 
" And TABLE2.UserID=" & uid 


that should work i believe....don't have anything to test it on right now but i will by the time your respond if this doesn't work.

Reply With Quote
  #3  
Old September 1st, 2003, 11:12 AM
benseri benseri is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Israel
Posts: 102 benseri User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via ICQ to benseri
This way I will have to write diffrent code to the records from Table1 and table2 and that would be like opening each of them apart...

I want to make the recordset be like a join of the to tables, with the same feilds, not in diffrent feilds... There is avcourse a problem this way because the ID feild that is AUTONUMBER can be the same for both tables, I don't have a problem with this, but maybe SQL will have...

Is there a way to join the tables temperntaly, only when the script is runing?

Reply With Quote
  #4  
Old September 1st, 2003, 02:55 PM
nopoints nopoints is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Windsor ON, Canada
Posts: 459 nopoints User rank is Corporal (100 - 500 Reputation Level)nopoints User rank is Corporal (100 - 500 Reputation Level)nopoints User rank is Corporal (100 - 500 Reputation Level)nopoints User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 13 h 44 m 22 sec
Reputation Power: 8
you can use UNION or UNION ALL if the data types of the fields you select are the same. i only difference between the two is UNION ALL removes duplicates.
__________________
Programmer's Corner

Reply With Quote
  #5  
Old September 1st, 2003, 09:22 PM
unatratnag unatratnag is offline
Average Intelligence
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2003
Location: Ohio/Chicago
Posts: 678 unatratnag User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 22 sec
Reputation Power: 6
Send a message via AIM to unatratnag
flip it nopoints, UNION removes duplicates i believe

Reply With Quote
  #6  
Old September 2nd, 2003, 08:07 AM
benseri benseri is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Israel
Posts: 102 benseri User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via ICQ to benseri
Thanks, I'll Check it out...

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Selecting Multiple Tables Using SELECT Statment 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 4 hosted by Hostway
Stay green...Green IT