-
Notifications
You must be signed in to change notification settings - Fork 849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
子查询被自动添加了ifnull,并且备用值为0,与返回值类型不一致 #1140
Comments
收到,晚上解决 |
2881099
added a commit
that referenced
this issue
Jun 2, 2022
2881099
added a commit
that referenced
this issue
Jun 2, 2022
2881099
added a commit
that referenced
this issue
Jun 2, 2022
哈哈,这效率没话说 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
var t = SqlService.Db.Select<LocationEntity>().LeftJoin(o => o.Id == o.GDAddress.LocationId) .Where(o => o.CollectTime == SqlService.Db.Select<LocationEntity>().As("b").Where(b=>b.DeviceCode == entity.DeviceCode).Max(b => b.CollectTime)) .First();
生成的SQL为
SELECT a.
Id
, a.Version
, a.IsDeleted
, a.CreatedTime
, a.ModifiedTime
, a.DeviceCode
, a.Latitude
, a.Longitude
, a.Altitude
, a.IsFromMockProvider
, a.CollectTime
, a.FormattedAddress
, a__GDAddress.Id
as13, a__GDAddress.Version
as14, a__GDAddress.CreatedTime
as15, a__GDAddress.LocationId
, a__GDAddress.GdLatitude
, a__GDAddress.GdLongitude
, a__GDAddress.FormattedAddress
as19, a__GDAddress.Country
, a__GDAddress.Province
, a__GDAddress.City
, a__GDAddress.Citycode
, a__GDAddress.District
, a__GDAddress.Adcode
, a__GDAddress.Township
, a__GDAddress.Towncode
FROM
Location
aLEFT JOIN
GDAddress
a__GDAddress ON a.Id
= a__GDAddress.LocationId
WHERE (a.
CollectTime
= ifnull((SELECT max(b.CollectTime
)FROM
Location
bWHERE (b.
DeviceCode
= '7678f598-3f8e-4e8c-90ee-dcd3c3041388') AND (b.IsDeleted
= 0)), 0)) AND (a.IsDeleted
= 0)limit 0,1
因为fnull备用值为0,子查询返回数据的数据类型为DATETIME
导致
Incorrect DATETIME value: '0'
The text was updated successfully, but these errors were encountered: