Results 1 to 12 of 12
  1. #1
    Join Date
    Apr 2004
    Posts
    75

    Unanswered: 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

  2. #2
    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

  3. #3
    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

  4. #4
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    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.

  5. #5
    Join Date
    Apr 2004
    Posts
    75
    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

  6. #6
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    use select col1, col2, col3 etc rather then the select *.

    specify your columns instead of just grabbing everything.

  7. #7
    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

  8. #8
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    It's the Friday before a long weekend so work isn't really keeping me very interested at the moment.

  9. #9
    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

  10. #10
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    Had a quick look over it. Looks okie....

  11. #11
    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

  12. #12
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •