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. C#
  4. JOIN

JOIN

Scheduled Pinned Locked Moved C#
helpquestion
3 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.
  • P Offline
    P Offline
    pat270881
    wrote on last edited by
    #1

    Hello, I have two tables From one table i want to retrieve two values and from the other also two values. And the condition is when the one value of the first table has a certain value. (In my case EngineerUserId). The problem is with my current statement the rows will be displayed two times. Have anybody know an idea? My current statement looks as follows: "SELECT p.JobId, p.Priority, c.CompanyName, c.ContactLName FROM JobDescription p INNER JOIN Client c ON p.EngineerUserId = ? ORDER BY p.Priority"; thx patrick

    C 1 Reply Last reply
    0
    • P pat270881

      Hello, I have two tables From one table i want to retrieve two values and from the other also two values. And the condition is when the one value of the first table has a certain value. (In my case EngineerUserId). The problem is with my current statement the rows will be displayed two times. Have anybody know an idea? My current statement looks as follows: "SELECT p.JobId, p.Priority, c.CompanyName, c.ContactLName FROM JobDescription p INNER JOIN Client c ON p.EngineerUserId = ? ORDER BY p.Priority"; thx patrick

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

      pat270881 wrote: SELECT p.JobId, p.Priority, c.CompanyName, c.ContactLName FROM JobDescription p INNER JOIN Client c ON p.EngineerUserId = ? ORDER BY p.Priority Do you mean the ? as a parameter placeholder of that you don't know what you should put there. If it is the latter then: INNER JOIN Client p.EngineerUserId = c._EquivalentColumnNameInClientTable_ If you need to add a condition you should add a WHERE clause before the ORDER BY so you might get something like this (I've assumed that the client table has a column called EngineerUserId, if it doesn't you need to replace it with the column that does contain that value)

      SELECT p.JobId, p.Priority, c.CompanyName, c.ContactLName
      FROM JobDescription p
      INNER JOIN Client c ON p.EngineerUserId = c.EngineerUserId
      WHERE p.EngineerUserId = ?
      ORDER BY p.Priority

      Oh, and by the way, this should really have gone in the SQL Forum[^]


      Do you want to know more?


      Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.

      P 1 Reply Last reply
      0
      • C Colin Angus Mackay

        pat270881 wrote: SELECT p.JobId, p.Priority, c.CompanyName, c.ContactLName FROM JobDescription p INNER JOIN Client c ON p.EngineerUserId = ? ORDER BY p.Priority Do you mean the ? as a parameter placeholder of that you don't know what you should put there. If it is the latter then: INNER JOIN Client p.EngineerUserId = c._EquivalentColumnNameInClientTable_ If you need to add a condition you should add a WHERE clause before the ORDER BY so you might get something like this (I've assumed that the client table has a column called EngineerUserId, if it doesn't you need to replace it with the column that does contain that value)

        SELECT p.JobId, p.Priority, c.CompanyName, c.ContactLName
        FROM JobDescription p
        INNER JOIN Client c ON p.EngineerUserId = c.EngineerUserId
        WHERE p.EngineerUserId = ?
        ORDER BY p.Priority

        Oh, and by the way, this should really have gone in the SQL Forum[^]


        Do you want to know more?


        Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.

        P Offline
        P Offline
        pat270881
        wrote on last edited by
        #3

        Okay, thank you, now it works! Thx patrick

        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