two columns in a listview can be from different tables???

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Vbbeginner07
    New Member
    • Dec 2007
    • 103

    two columns in a listview can be from different tables???

    say id and name be two columns in a listview,wher both are from two differnt tables,
    1st table contains id and name
    11nd table contains id and age,11nd table contains ids from first table but not whole ids but half of it...

    how can we write the code in vb
  • CyberSoftHari
    Recognized Expert Contributor
    • Sep 2007
    • 488

    #2
    Explain your problem detail and no confuse. Are you talking about Inner Join or Left Join Sql queries?

    Comment

    • lotus18
      Contributor
      • Nov 2007
      • 865

      #3
      Originally posted by Vbbeginner07
      say id and name be two columns in a listview,wher both are from two differnt tables,
      1st table contains id and name
      11nd table contains id and age,11nd table contains ids from first table but not whole ids but half of it...

      how can we write the code in vb
      This could be done in your query.

      Rey Sean

      Comment

      • Vbbeginner07
        New Member
        • Dec 2007
        • 103

        #4
        Originally posted by CyberSoftHari
        Explain your problem detail and no confuse. Are you talking about Inner Join or Left Join Sql queries?
        in a single form 2 listview controls,one listview contains....id and name
        11nd listview contains work doneby employee(in hours)

        in the first listview control,id and name,where id cmes from table say tab1 which has columns id,workdone,gro ss salary(of emp)
        11nd listview control,workdon e(in hours)
        my doubt occurs here where id can be added from tab1 and i need name to populate from table tab2
        tab1-id,name,age
        tab2-id,workdone,gro sssalary
        whereas all ids in tab1 is not there in tab2

        thanks in advance

        Comment

        • jamesd0142
          Contributor
          • Sep 2007
          • 471

          #5
          Originally posted by lotus18
          This could be done in your query.

          Rey Sean
          Really, i tried this:

          "select * from TBLUsers Select * from TBLOther"
          and it didnt work
          but when i simply use 1 select statemement:
          "select * from TBLUsers"
          it works fine...

          Can you explain by anychance?

          Comment

          • CyberSoftHari
            Recognized Expert Contributor
            • Sep 2007
            • 488

            #6
            Originally posted by Vbbeginner07
            i..
            whereas all ids in tab1 is not there in tab2
            thanks in advance
            I can assume what you are trying,
            1. keep tab2 listview empty and fill the tab1 listview1 with your select query (or in your way).
            2. when user click tab1 listview (in tab1 listview click event fill tab 2 listview with selected value from tab1 listview) and show tab2 listview.

            Comment

            • debasisdas
              Recognized Expert Expert
              • Dec 2006
              • 8119

              #7
              Originally posted by Vbbeginner07
              say id and name be two columns in a listview,wher both are from two differnt tables,
              1st table contains id and name
              11nd table contains id and age,11nd table contains ids from first table but not whole ids but half of it...

              how can we write the code in vb
              you need to use JOIN in SQL query to retrive matching data from both the tables
              else create a view based on join and select data from the view and populate the listview.

              Comment

              • CyberSoftHari
                Recognized Expert Contributor
                • Sep 2007
                • 488

                #8
                for the above suggestion we don’t need joins. (Of-course joins and grouping is required but not in this case is it?)

                Comment

                • debasisdas
                  Recognized Expert Expert
                  • Dec 2006
                  • 8119

                  #9
                  Originally posted by CyberSoftHari
                  for the above suggestion we don’t need joins. (Of-course joins and grouping is required but not in this case is it?)
                  Join is required if using only 1 list view.

                  if want to use two pass the vale from listview1 and pass that to SQL query ,fetch the data and populate the second.

                  Comment

                  • jamesd0142
                    Contributor
                    • Sep 2007
                    • 471

                    #10
                    Originally posted by debasisdas
                    Join is required if using only 1 list view.
                    Cheers debasisdas works great now

                    Comment

                    Working...