SQL?
-
I have two tables in my xmlfile table0 and table1.table0 has 5 columns; itemid, checkno, payee, amount, & date. table1 has only one column; balance I need the tables to be joined together so that instead of my datagrid showing only table0 it will show both table 0 and 1. so since table0 is the first 5 columns i need to get table1 to be the 6th.the reason for this is because later on i am going to try to get amount from table0 to subtract from balance in table1 and the sum will end up in the balance column of the next row . this will eventually need to happen over and over again(loop). can anyone help me with joining these it would be greatly appreciated. happy holidays
-
I have two tables in my xmlfile table0 and table1.table0 has 5 columns; itemid, checkno, payee, amount, & date. table1 has only one column; balance I need the tables to be joined together so that instead of my datagrid showing only table0 it will show both table 0 and 1. so since table0 is the first 5 columns i need to get table1 to be the 6th.the reason for this is because later on i am going to try to get amount from table0 to subtract from balance in table1 and the sum will end up in the balance column of the next row . this will eventually need to happen over and over again(loop). can anyone help me with joining these it would be greatly appreciated. happy holidays
There should some common columns in both the tables to join, If you wish to join the tables. Table1 should have some primary key like itemId, and should become the Master Table. I would advice u to add the column in Table1. Finally, It should be like Table0 ----- ItemId CheckNum Payee Amount PaymentDate Table1 ----- ItemId Balance Finally the query will be Select A.ItemId, A.CheckNum, A.Payee, A.Amount, A.PaymentDate, B.Balance From Table0 A, Table1 B Where A.ItemId = B.ItemId
-
There should some common columns in both the tables to join, If you wish to join the tables. Table1 should have some primary key like itemId, and should become the Master Table. I would advice u to add the column in Table1. Finally, It should be like Table0 ----- ItemId CheckNum Payee Amount PaymentDate Table1 ----- ItemId Balance Finally the query will be Select A.ItemId, A.CheckNum, A.Payee, A.Amount, A.PaymentDate, B.Balance From Table0 A, Table1 B Where A.ItemId = B.ItemId
Also, make sure that Table0.ItemID is a unique primary key, or you'll potentially introduce data integrity issues. if you want my opinion, there is no reason why your balance column should not be included inside of table0. If it is a true one to one relation like that then there is no need to create two tables and join them as that's just more overhead for your server to handle every time you request it and is just plain un-clean datbase design. However if the balance is a one-to-many relationship, like a date range, then you'd need to include that column in table1. given what you're saying there's just no need to include the balance column in a seperate table :)
'Cause I'm living on things that excite me, be it pastries or lobsters or love...
I'm just trying to get by, being quiet and shy, in a world full of push and shove... Jimmy Buffett - The Wino and I know -
Also, make sure that Table0.ItemID is a unique primary key, or you'll potentially introduce data integrity issues. if you want my opinion, there is no reason why your balance column should not be included inside of table0. If it is a true one to one relation like that then there is no need to create two tables and join them as that's just more overhead for your server to handle every time you request it and is just plain un-clean datbase design. However if the balance is a one-to-many relationship, like a date range, then you'd need to include that column in table1. given what you're saying there's just no need to include the balance column in a seperate table :)
'Cause I'm living on things that excite me, be it pastries or lobsters or love...
I'm just trying to get by, being quiet and shy, in a world full of push and shove... Jimmy Buffett - The Wino and I knowPlease reply to Mr. beginner1 , By mistake your reply has come to me. BTW, Thanks for added attension. Regards, Jay
-
Also, make sure that Table0.ItemID is a unique primary key, or you'll potentially introduce data integrity issues. if you want my opinion, there is no reason why your balance column should not be included inside of table0. If it is a true one to one relation like that then there is no need to create two tables and join them as that's just more overhead for your server to handle every time you request it and is just plain un-clean datbase design. However if the balance is a one-to-many relationship, like a date range, then you'd need to include that column in table1. given what you're saying there's just no need to include the balance column in a seperate table :)
'Cause I'm living on things that excite me, be it pastries or lobsters or love...
I'm just trying to get by, being quiet and shy, in a world full of push and shove... Jimmy Buffett - The Wino and I knowSo even if I want to make payee from table0 subtract from balance I can still do this if balance is included in table0? Thanks
-
So even if I want to make payee from table0 subtract from balance I can still do this if balance is included in table0? Thanks
My mistake I meant amount subtract from balance not payee. so this will still work even if They are in the same table? Thanks