我有两个表,用户和会话。每个用户可以有多个会话。我想获取用户名和他最近一次会话的日期。但我需要这样做,以便能够返回按上次会话日期排序的数组。此外,某些用户可能没有会话,因此左连接将不返回任何日期。
SELECT u.name, max(s.sdate) FROM users u
LEFT JOIN sessions s ON s.uid=u.id
ORDER BY s.sdate
LIMIT 25,25
显然这不起作用,但我想要一些简单的东西。相似的东西?请注意,我还需要指定由于分页而返回的行集。这将是第2页。我确实看到了类似的帖子,但它们对我的使用来说过于复杂。
我保持这种简化以便于理解。
答案 0 :(得分:1)
我相信你的情况你只需要按用户分组你的结果。 尝试
Preparing
Analyzing dependencies
Inspecting targets to integrate
Using `ARCHS` setting to build architectures of target `Pods`: (``)
Finding Podfile changes
- AFNetworking
- Masonry
- NIMSDK
Resolving dependencies of `Podfile`
Comparing resolved specification to the sandbox manifest
- AFNetworking
- Masonry
- NIMSDK
Downloading dependencies
-> Using AFNetworking (2.5.4)
-> Using Masonry (0.6.2)
-> Using NIMSDK (1.2.0)
- Running pre install hooks
Generating Pods project
- Creating Pods project
- Adding source files to Pods project
- Adding frameworks to Pods project
- Adding libraries to Pods project
- Adding resources to Pods project
- Linking headers
- Installing targets
- Installing target `AFNetworking` iOS 7.0
- Installing target `Masonry` iOS 7.0
- Installing target `Pods` iOS 7.0
- Running post install hooks
- Writing Xcode project file to `Pods/Pods.xcodeproj`
- Writing Lockfile in `Podfile.lock`
- Writing Manifest in `Pods/Manifest.lock`
Integrating client project
Integrating target `Pods` (`XXXX.xcodeproj` project)
- Running post install hooks
- cocoapods-stats from `/Library/Ruby/Gems/2.0.0/gems/cocoapods-stats-0.5.3/lib/cocoapods_plugin.rb`
Sending stats
- AFNetworking, 2.5.4
- Masonry, 0.6.2
- NIMSDK, 1.2.0
Failed to send stats: SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: sslv3 alert handshake failure