Howto do inner joins and compare on tabel to tabel fields

Posts   
 
    
Troels
User
Posts: 1
Joined: 08-Jul-2005
# Posted on: 08-Jul-2005 12:31:59   

Hi,

I wanted to do a select statement in code by using the predicat bucket and filtering but I can not figure out how to "translate" my select statement into the correct calls. fx how do i do multible inner joins and how do i compare one table field to another table field. I got irritated rage and did a stored procedure instead, but it must be possible to do this the "nice" way... disappointed My stored procedure is like this:

CREATE procedure dbo.UserWorkingStatus
    @UserId varchar(100)
as

SELECT
 Company.Name,
 Revision.CorrectedDate,
 Revision.EditStatus
FROM
 bb.Company Company 
INNER JOIN bb.Revision Revision ON
 Company.RevisionId = Revision.RevisionId 
INNER JOIN bb.UserAccess UserAccess ON
 Company.CommonCompanyId = UserAccess.CommonCompanyId
WHERE
(Revision.EditStatus = '1' OR  Revision.EditStatus = '0') 
AND (UserAccess.UserId = @UserId) AND (Revision.CorrectingUserId = @UserId)
GO
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 08-Jul-2005 20:32:51   

You select statement is pretty straightforward so this is definitely possible with predicates and relations, could you please paste the code you tried? (If you still have it)

Frans Bouma | Lead developer LLBLGen Pro