JOIN
-
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
-
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
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.PriorityOh, and by the way, this should really have gone in the SQL Forum[^]
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.
-
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.PriorityOh, and by the way, this should really have gone in the SQL Forum[^]
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.