If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Connecting two tables from one DB

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-22-04, 09:34
breeze76 breeze76 is offline
Registered User
 
Join Date: Apr 2004
Posts: 75
Connecting two tables from one DB

If you connect to one DB, in the sql statement how would you connect to two(2) tables? Then when you want that info shown in a table how would you code it so it would know which table to pull from?

Thanks

breeze76
Reply With Quote
  #2 (permalink)  
Old 04-22-04, 11:48
breeze76 breeze76 is offline
Registered User
 
Join Date: Apr 2004
Posts: 75
OK.. Is this how I would do it:

DIM sqlstr1, sqlstr2

sqlstr1=SELECT * tablename1
sqlstr2=SELECT * tablename2

Or should I or could I put them into on sql statement?

Then when I want to call the info from a table would I do it like this:

<%=sqlstr1'(fieldname here)'%> and do I need quotes anywhere??

breeze76
Reply With Quote
  #3 (permalink)  
Old 04-22-04, 12:49
breeze76 breeze76 is offline
Registered User
 
Join Date: Apr 2004
Posts: 75
Ok seems I am posting to myself.. but here goes.. I just need someone to look over what I am posting and to give me guidance....

Ok if I query both tables and all the info in them as I am trying to do in the first post, I guess the best way to do different things would be to call sql functions depending on what the user wants. Then I would need different tables depending on which function they call. Then I could do an IF THEN to determine which function was call and to match it to which table.

Would this be a way of doing this?

breeze76
Reply With Quote
  #4 (permalink)  
Old 04-22-04, 19:55
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
you are kinda skipping a phase or two,... something more like this

Code:
Dim strSql1, strSql2
strSql1="Select * from table1"
strSql2="Select * from table2"

Dim recordset1, recordset2
set recordset1 = myConnection.Execute(strSQL1)
set recordset2 = myConnection.Execute(strSQL2)

<%=recordset1(fieldname here)'%>
Don't forget to set your recordsets to nothing once you have finished and please, you should avoid using select *, specify the column names it's much nicer.
Reply With Quote
  #5 (permalink)  
Old 04-22-04, 22:40
breeze76 breeze76 is offline
Registered User
 
Join Date: Apr 2004
Posts: 75
Quote:
Originally posted by rokslide
you are kinda skipping a phase or two,... something more like this

Code:
Dim strSql1, strSql2
strSql1="Select * from table1"
strSql2="Select * from table2"

Dim recordset1, recordset2
set recordset1 = myConnection.Execute(strSQL1)
set recordset2 = myConnection.Execute(strSQL2)

<%=recordset1(fieldname here)'%>
Don't forget to set your recordsets to nothing once you have finished and please, you should avoid using select *, specify the column names it's much nicer.
OK, if not SELECT, then what should I use?

breeze76
Reply With Quote
  #6 (permalink)  
Old 04-22-04, 22:42
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
use select col1, col2, col3 etc rather then the select *.

specify your columns instead of just grabbing everything.
Reply With Quote
  #7 (permalink)  
Old 04-22-04, 22:49
breeze76 breeze76 is offline
Registered User
 
Join Date: Apr 2004
Posts: 75
WOW!!!

That was a quick reply...

Thanks, I am sur I will have more questions for you tonight anyways, am getting ready to start working on all this stuff... to bad I could not send some your way...


Thanks

breeze76
Reply With Quote
  #8 (permalink)  
Old 04-22-04, 22:58
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
It's the Friday before a long weekend so work isn't really keeping me very interested at the moment.
Reply With Quote
  #9 (permalink)  
Old 04-22-04, 23:14
breeze76 breeze76 is offline
Registered User
 
Join Date: Apr 2004
Posts: 75
Well.. one more day here and it will be the weekend.. but I have a ton of stuff to do on our website.. hey, take a look at it, it is my very first web site, third version thought... Let me know what you think and if you have any suggestion for me..

www.psrdocs.com

breeze76
Reply With Quote
  #10 (permalink)  
Old 04-22-04, 23:23
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
Had a quick look over it. Looks okie....
Reply With Quote
  #11 (permalink)  
Old 04-22-04, 23:33
breeze76 breeze76 is offline
Registered User
 
Join Date: Apr 2004
Posts: 75
Thanks. another quick question.. I do not want to use a table or should I, I would like my data results postes in a paragraph type layout.

How would I do that, I can do tables, but not like the paragraph type.

breeze76
Reply With Quote
  #12 (permalink)  
Old 04-22-04, 23:38
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
I'm not quite sure I understand. You can use whatever layout you want... and use tables if you need to or not... it really depends on what works best for you...

If you want a suggestion as to what style would look best, whip up a couple of pages and I'll have a look at them and let you know what I like best... you could even post a poll and get other peoples opinions.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On