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. Web Development
  3. ASP.NET
  4. Sql statement

Sql statement

Scheduled Pinned Locked Moved ASP.NET
helplearningdatabasequestion
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.
  • C Offline
    C Offline
    Commickey
    wrote on last edited by
    #1

    Hello, I have three tables: Personnel, Course, Education. with persid the primary key of the personnel table and foreign key in the other two tables. My problem is: Show personnel details that are either following a course or an education. Can some one please help? thanks alot, Commickey

    C 1 Reply Last reply
    0
    • C Commickey

      Hello, I have three tables: Personnel, Course, Education. with persid the primary key of the personnel table and foreign key in the other two tables. My problem is: Show personnel details that are either following a course or an education. Can some one please help? thanks alot, Commickey

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      I'm assuming from your title that you want help with the SQL statement

      SELECT *
      FROM Personnel AS p
      INNER JOIN Course AS c ON c.persid = p.persid
      WHERE ...

      or

      SELECT *
      FROM Personnel AS p
      INNER JOIN Education AS e ON e.persid = p.persid
      WHERE ...

      Without more information that is as much as I can help you with


      Scottish Developers events: * .NET debugging, tracing and instrumentation by Duncan Edwards Jones and Code Coverage in .NET by Craig Murphy * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog

      C 1 Reply Last reply
      0
      • C Colin Angus Mackay

        I'm assuming from your title that you want help with the SQL statement

        SELECT *
        FROM Personnel AS p
        INNER JOIN Course AS c ON c.persid = p.persid
        WHERE ...

        or

        SELECT *
        FROM Personnel AS p
        INNER JOIN Education AS e ON e.persid = p.persid
        WHERE ...

        Without more information that is as much as I can help you with


        Scottish Developers events: * .NET debugging, tracing and instrumentation by Duncan Edwards Jones and Code Coverage in .NET by Craig Murphy * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog

        C Offline
        C Offline
        Commickey
        wrote on last edited by
        #3

        I want to select information of personel in schools and personeels in curses and display at once... so my querry should contain three of the tables at once... any help?

        C 1 Reply Last reply
        0
        • C Commickey

          I want to select information of personel in schools and personeels in curses and display at once... so my querry should contain three of the tables at once... any help?

          C Offline
          C Offline
          Colin Angus Mackay
          wrote on last edited by
          #4

          SELECT *
          FROM Personnel AS p
          INNER JOIN Education AS e ON e.persid = p.persid
          INNER JOIN Course AS c on c.persid = p.persid
          WHERE ...


          Scottish Developers events: * .NET debugging, tracing and instrumentation by Duncan Edwards Jones and Code Coverage in .NET by Craig Murphy * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog

          C 1 Reply Last reply
          0
          • C Colin Angus Mackay

            SELECT *
            FROM Personnel AS p
            INNER JOIN Education AS e ON e.persid = p.persid
            INNER JOIN Course AS c on c.persid = p.persid
            WHERE ...


            Scottish Developers events: * .NET debugging, tracing and instrumentation by Duncan Edwards Jones and Code Coverage in .NET by Craig Murphy * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog

            C Offline
            C Offline
            Commickey
            wrote on last edited by
            #5

            some personeel have education history others have short course history I have 3 tables: Personeel, Courses and Education. Personeel table have primary key persId which is foreign in the other 2. My question: How do I get the personel details of: those havin education history those having course history Combine the above two in one list and display as just a single list in a datagrid? This will become the list of active employees. How will the querry look like and what other things do I need to do... I have tried several things out but I am really stuck. Thanks alot, Commickey

            Y 1 Reply Last reply
            0
            • C Commickey

              some personeel have education history others have short course history I have 3 tables: Personeel, Courses and Education. Personeel table have primary key persId which is foreign in the other 2. My question: How do I get the personel details of: those havin education history those having course history Combine the above two in one list and display as just a single list in a datagrid? This will become the list of active employees. How will the querry look like and what other things do I need to do... I have tried several things out but I am really stuck. Thanks alot, Commickey

              Y Offline
              Y Offline
              YossiKahlon
              wrote on last edited by
              #6

              One option: Select t1.persId, t2.courseDate, t2.courseName, t3.educationDate, t3.educationName from (Personal t1 full outer join Course on t1.persId = t2.persId) full outer join Education t3 on t1.persId = t3.persId where ...... ..... Second option Select t1.persId, t2.courseDate, t2.courseName from Personal t1 full outer join Course on t1.persId = t2.persId where ... ... union all Select t1.persId, t2.educationDate, t2.educationName from Personal t1 full outer join Education on t1.persId = t2.persId where ... ... Both query will give you the result. The first query works in Oracle - If you need SQL server I will help you - Actually I tested it and it works fine on sqlserver or any other ANSI RDBMS. Yossi Kahlon -- modified at 10:55 Wednesday 21st June, 2006

              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