I have 3 tables having this unique id one of them has a different type of data type.
The following is the data type in the 4 tables representing the same column :
users : userid(varchar(20))
finewaiver : Requester(int)
loanstudents : student(int)
This statement works without the where criteria, but when I tried adding the search criteria there was some error. Although this is not the correct as it is a long way to produce the same result below and it might affect performance by joining too many redundant tables. I just want to know the logic of why it did failed. Loanstudents was never needed in the first place as the finewaiver already holds the necessary info for loans and the requester table. Its either I change the whole statement to the one in the workaround or I needed to cast the @userid to a varchar(20) type.
Select * from fineswaiver fw
join loans l on l.ID = fw.LoanID
join LoanStudents ls on ls.LoanID = l.ID
join Users u on u.ID = ls.student
where u.userid =@userid
This was my workaround and it works :
Select * from fineswaiver fw
join Users u on u.ID = fw.Requester
join loans l on l.ID = fw.LoanID
join LoanStudents ls on ls.LoanID = l.ID
Where u.userid =@userid