Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. SQL?

SQL?

Scheduled Pinned Locked Moved Visual Basic
databasehelpquestion
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Makniteasy
    wrote on last edited by
    #1

    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

    J 1 Reply Last reply
    0
    • M Makniteasy

      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

      J Offline
      J Offline
      Jay Shankar
      wrote on last edited by
      #2

      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

      S 1 Reply Last reply
      0
      • J Jay Shankar

        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

        S Offline
        S Offline
        ScottSingleton
        wrote on last edited by
        #3

        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

        J M 2 Replies Last reply
        0
        • S ScottSingleton

          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

          J Offline
          J Offline
          Jay Shankar
          wrote on last edited by
          #4

          Please reply to Mr. beginner1 , By mistake your reply has come to me. BTW, Thanks for added attension. Regards, Jay

          1 Reply Last reply
          0
          • S ScottSingleton

            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

            M Offline
            M Offline
            Makniteasy
            wrote on last edited by
            #5

            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

            M 1 Reply Last reply
            0
            • M Makniteasy

              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

              M Offline
              M Offline
              Makniteasy
              wrote on last edited by
              #6

              My mistake I meant amount subtract from balance not payee. so this will still work even if They are in the same table? Thanks

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups