The theory behind this , i wanna know for what reason, employees have terminated and then , I inner join 2 table (Termination Reasons with Users) were the two talk to the each other and Termination Reasons table contains 2 column (Id (int) , Name(varchar)) and the other one , Users Table contains 1 column (EmploymentStatusId (int)) .
I can use EmploymentStatusId(int) from tbl Users with Id (int) from another table wich is Termination Reasons beacuse , both of them have same data type (int):
SELECT
u.EmploymentStatusId AS Status
FROM
x AS p INNER JOIN y AS u ON u.Id=x
INNER JOIN x AS t ON t.Id = y
WHERE r=214 order by g;
But when i try using EmploymentStatusId (int) from tbl Users with Name (varchar) from tbl Termination Reasons , i got problem:
SELECT
w AS Status
FROM
s AS p INNER JOIN s AS u ON u.q=v
INNER JOIN v AS t ON t.Name = n
WHERE f=214 order by h;
And then
Error :
Conversion failed when converting the varchar value 'TerminatedByCompany' to data type int.
i know why ,because they have different data type , therefore they can not talk to the each other.
but i tried also to solve this with Convert but idont know ,why or how is not working.
Can someone please help or point me in the right direction. Thanks.
The Query ,where i tried with CONVERT ,its look like this:
SELECT
CONVERT(INT, CONVERT(VARCHAR(12), t.Name)) as Status
FROM
s AS p INNER JOIN t AS u ON j=u
INNER JOIN z AS t ON z = z
WHERE z=214 order by b;
What I have tried:
i tried also to solve this with Convert but idont know ,why or how is not working.Can someone please help or point me in the right direction. Thanks.