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. Database & SysAdmin
  3. Database
  4. joining two tables

joining two tables

Scheduled Pinned Locked Moved Database
comquestion
7 Posts 2 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.
  • E Offline
    E Offline
    Erdinc27
    wrote on last edited by
    #1

    i want to join two tables(Firms and People) to show them in datagridview with ascending order in my program side but the thing is that they dont have any common point.so can i join them ?

    vemedya.com

    E 1 Reply Last reply
    0
    • E Erdinc27

      i want to join two tables(Firms and People) to show them in datagridview with ascending order in my program side but the thing is that they dont have any common point.so can i join them ?

      vemedya.com

      E Offline
      E Offline
      Estys
      wrote on last edited by
      #2

      Sure you can, for instance :

      select firms.nmbr as nmbr, firms.name as name, "firm" as type from firms
      UNION
      select people.id as nmbr, people.surname as name, "people" as type from people;

      The UNION keyword joins the two result sets. Cheers

      I don't like my signature at all

      E 1 Reply Last reply
      0
      • E Estys

        Sure you can, for instance :

        select firms.nmbr as nmbr, firms.name as name, "firm" as type from firms
        UNION
        select people.id as nmbr, people.surname as name, "people" as type from people;

        The UNION keyword joins the two result sets. Cheers

        I don't like my signature at all

        E Offline
        E Offline
        Erdinc27
        wrote on last edited by
        #3

        yeah it worked..thanks Estys..one more question it showed the datas as ordered already actually i wished that so it works always like that or i am lucky :)

        vemedya.com

        E 1 Reply Last reply
        0
        • E Erdinc27

          yeah it worked..thanks Estys..one more question it showed the datas as ordered already actually i wished that so it works always like that or i am lucky :)

          vemedya.com

          E Offline
          E Offline
          Estys
          wrote on last edited by
          #4

          Without seeing your query, I think that's just blind chance :-D . Cheers

          I don't like my signature at all

          E 1 Reply Last reply
          0
          • E Estys

            Without seeing your query, I think that's just blind chance :-D . Cheers

            I don't like my signature at all

            E Offline
            E Offline
            Erdinc27
            wrote on last edited by
            #5

            my query is here

            select firma_adi[Kişi/Firma],telefon1[Telefon No],telefon2[Telefon No],Telefon3[Telefon No],Telefon4[Telefon No],Telefon5[Telefon No] from Firmalar
            Union
            select kisi[Kişi/Firma],numara1[Telefon No],numara2[Telefon No],numara3[Telefon No],Numara4[Telefon No],Numara5[Telefon No] from Rehber

            vemedya.com

            E 1 Reply Last reply
            0
            • E Erdinc27

              my query is here

              select firma_adi[Kişi/Firma],telefon1[Telefon No],telefon2[Telefon No],Telefon3[Telefon No],Telefon4[Telefon No],Telefon5[Telefon No] from Firmalar
              Union
              select kisi[Kişi/Firma],numara1[Telefon No],numara2[Telefon No],numara3[Telefon No],Numara4[Telefon No],Numara5[Telefon No] from Rehber

              vemedya.com

              E Offline
              E Offline
              Estys
              wrote on last edited by
              #6

              You can order the data with the ORDER BY clause. If all select statements use the same fieldnames you can use "ORDER BY <fieldname>", otherwise you can use the form "ORDER BY 2" where the "2" is the position of the field. Cheers

              I don't like my signature at all

              E 1 Reply Last reply
              0
              • E Estys

                You can order the data with the ORDER BY clause. If all select statements use the same fieldnames you can use "ORDER BY <fieldname>", otherwise you can use the form "ORDER BY 2" where the "2" is the position of the field. Cheers

                I don't like my signature at all

                E Offline
                E Offline
                Erdinc27
                wrote on last edited by
                #7

                yeah it works with order too..thanks for your time

                vemedya.com

                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