【发布时间】:2018-10-17 21:27:58
【问题描述】:
我在 MySQL 数据库中有两个表。第一个表是contacts(customer, id),用于存储客户信息。第二个表history(report, nextFollowingDate, customerid) 存储客户联系的历史记录以及下一个后续日期。一个客户可以有多个nextFollowingDate 值不同的记录。
样本数据如下。
contacts表:
customer id
a 1
b 2
c 3
history表:
report nextFollowingDate customerid
report1 2018/04/23 1
report2 2018/04/25 1
report3 2018/04/22 2
report4 2018/04/26 3
report5 2018/05/30 2
我想按nextFollowingDate 的值按升序对联系人表中的客户进行排序。如下所示。
customer nextFollow
1 2018/04/25
2 2018/05/30
3 2018/04/26
但我没有办法这样做。
【问题讨论】:
-
你试过在mysql中执行吗?
-
当您提出问题时,请尽量提供Minimal, Complete and Verifiable Example。如果你这样做,提供答案的发布者会发现他们很容易重现场景,并且答案会很有成效。对于这样的案例,您可以使用SQL Fiddle,这对于尝试回答的人来说会很容易。 :)
标签: mysql select sql-order-by