我有 2 个具有相同架构的表(THour_IN 和 THour_OUT): THour_IN 的列:名称|日期|HourIN THour_OUT 的列:名称|日期|HourOUT 我进行查询:
SELECT THour_IN.Name, THour_IN.date, THour_IN.HourIN, THour_OUT.HourOUT FROM THour_IN LEFT JOIN THour_OUT ON (Hour_IN.Name = THour_OUT.Name) AND (Hour_IN.date = THour_OUT.date);
但这在我的情况下是不正确的,因为我在表格中有多个具有相同日期的行。结果是:
Name date HourIN HourOUT
AAA 24/11/2013 17:33:06 20:33:27
AAA 24/11/2013 17:33:06 16:36:06
AAA 24/11/2013 07:33:27 20:33:27
AAA 24/11/2013 07:33:27 16:36:06
BBB 18/11/2013 16:36:06
BBB 19/11/2013 07:33:30
BBB 21/11/2013 07:29:24 08:33:22
BBB 22/11/2013 07:33:30 16:34:53
日期应为 24/11/2013 First HourIN(07:33:27) with First HourOUT (16:36:06), Second HourIN (17:33:06) with Second HourOUT (20:33:06) Any想法?