This topic is locked

Database Query

7/1/2005 5:57:36 AM
ASPRunnerPro General questions
S
shahram author

I have a DSN database with 3 tables,

  1. Accounts which contains the Username and user data information and Account ID column as the key field (though username could be the keyfram as they are unique in this table)

    2.Accountbills

    3.Acount history

    bills and history have the 1 column of Username, and the information regardng them which means there could be multiple usernames in one colum with their actions at different times,
    without the account bills and history, i am fine,

    users can see there data and edit it in the account table

    however i want them to also be able too see there bills and history in the detail page of viwing their information
    What i did was where we could chose the the tables for both bills and history, for master-detail relationship i put the Accounts table as the Master and, the primary key the Username, and Foreign key Username
    but my problems are now

    first of all i don't know how to query their data together with the main data

    i tried from SQL query

    select [UserName], ...... From [Accounts]

    select [ProductName], [Count], [Price] From [AccountBill]

    ....
    whic doesn't work

    each query works fine seperatly
    and my other problem is how to show theire details for each user in their account view page,
    Please help me to fix this,

admin 7/5/2005

You do not need to modify SQL query in order to use Master-Details relationships.
SImply define one table as Master and another one is Details choosing correct fields to link these tables. Thats all you need to do. ASPRunner will do the rest for you.

S
shahram author 7/5/2005

What i was planning to do was to show informatioms from one table that corresponds to users from another table(main table) , under the information of that user in the main table
but i guess it's only possible to show tabels seperatly but not under another table
I have an internet cafe that stores Users information in table Accounts and their usage and bills in another table, I would want them to be able to see their history and bills (2 diffenet tables), when they are browsing their user information from Accounts table,
if it woudln't be possible to do it through program, i guess i'll have to manipulate the code manually , if that would be possible!!!!

admin 7/5/2005

Try the following:

select a.[UserName], b.[ProductName], b.[Count], b.[Price] From [Accounts] a

inner join [AccountBill] b

on a.UserID = b.UserID


Make sure you pick correct fields to join these tables.