Results 1 to 9 of 9

Thread: Procedure or SQL to combine tables

  1. #1
    Join Date
    Jun 2005
    Posts
    4

    Procedure or SQL to combine tables

    Ok,
    we have 2 tables in SQL.
    and need to do this using procedure or straight SQL.
    I attached the picture for a better understanding.
    Anyone can help?
    The only problem is - 2 top tables are changing all the time. Sothere could be more responses or more names in both tables.
    Attached Images Attached Images

  2. #2
    Join Date
    Feb 2003
    Posts
    1,048
    Can you explain a little better what you are trying to do? Remember, we have no idea what is going on in your tables or what you are trying to do. "Combine two tables" isn't very descriptive.

  3. #3
    Join Date
    Jun 2005
    Posts
    4
    Im trying to build new table - if you look at the picture.
    I need a procedure that will create new dynamic table from other 2.

  4. #4
    Join Date
    Feb 2003
    Posts
    1,048
    I looked at the picture. It doesn't tell the logic required to determine what goes where.

  5. #5
    Join Date
    Jun 2005
    Posts
    4
    All the fields from the first table will be titles, headers on a new table in .asp file.
    All the responses will be there for each title, heading. What is not understandable here?
    I have 2 tables in SQL and I need to output table in .asp combining those 2 dynamic tables and building new one in .asp as I said.
    I tried in VB - didn't work. So I'm thinking if someone can help with procedure to do that, it would be great.

  6. #6
    Join Date
    Feb 2003
    Posts
    1,048
    Quote Originally Posted by tupoy
    All the fields from the first table will be titles, headers on a new table in .asp file.
    All the responses will be there for each title, heading. What is not understandable here?
    Well, this is the first time you posted that you are doing it in ASP and are doing an HTML table on a web page. When you post on a database forum that you need help making a table, we assume that you mean a database table unless you say otherwise. We're not mind readers.

    You're going to have to do two separate queries. The first query would retrieves the table headers from your first database. The second query would be the recordset of data you want displayed. Output the headers and then the recordset.

  7. #7
    Join Date
    Jun 2005
    Posts
    7
    Even I thought so and I was getting ready to type the reply and found Rawhide
    Moderator 's mail. Thank You for saving my effort

  8. #8
    Join Date
    Jun 2005
    Posts
    4
    Quote Originally Posted by Rawhide
    Well, this is the first time you posted that you are doing it in ASP and are doing an HTML table on a web page. When you post on a database forum that you need help making a table, we assume that you mean a database table unless you say otherwise. We're not mind readers.

    You're going to have to do two separate queries. The first query would retrieves the table headers from your first database. The second query would be the recordset of data you want displayed. Output the headers and then the recordset.
    How would I do that when I have dynamic table in SQL?
    The amount of records changes all the time. So do Headers.

  9. #9
    Join Date
    Feb 2003
    Posts
    1,048
    Do a "Select *" query and then cycle throught he field object to access each column individually. Below is a code snippet that demonstrates what I mean.

    iCount = 0

    For Each oField In oRS.Fields
    Response.Write "<td align=center><b>" & oRS.Fields(iCount).Name & "</b></td>"
    iCount = iCount + 1
    Next

Posting Permissions

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