开发者

T-SQL LEFT JOIN on bigint id return only ids lower than 101 on right table

开发者 https://www.devze.com 2023-03-31 02:55 出处:网络
I have two tables on a Sql Server 2008. ownership with 3 fields and case with another 3 fields I need to join both on the ID field (bigint).

I have two tables on a Sql Server 2008. ownership with 3 fields and case with another 3 fields I need to join both on the ID field (bigint).

For testing purposes I'm only using one field from each table. This field is bigint and has values from 1 to 170 (for now).

My query is:

S开发者_如何学GoELECT DISTINCT
    ownership.fCase,
    case.id
FROM
    ownership LEFT JOIN case ON (case.id=ownership.fCase)
WHERE 
    ownership.dUser='demo' 

This was expected to return 4 rows with the same values on both columns. Problem is that the last row of the right table comes as null for the fCase = 140. This is the only value above 100.

If I run the query without the WHERE clause it show all rows on the left table but the values on the right only apear if below 101 otherwise shows null.

Can someone help me, am I doing something wrong or is this a limitation or a bug?


Case is also a verb so it may be getting confused. Try your table and column names in []. E.G. [case].[id] = [ownership].[fCase]. Are you like double check sure that [case].[id] and [ownership].[fCase] are both bigint. If your current values are 1-170 then why bigint (9,223,372,036,854,775,807)? Does that column accept nulls?

0

精彩评论

暂无评论...
验证码 换一张
取 消