我的两张桌子是这样的
工作台
buyer timeArrived billed paid
ABC 2013-02-08 10:30:00 60$ 45$
CTS 2013-02-18 10:30:00 100$ 80$
ABC 2012-03-11 10:30:00 60$ 40$
MNT 2012-02-08 10:30:00 100$ 60$
CTS 2012-03-11 10:30:00 60$ 40$
购买者_t 表
buyer
ABC
MNT
CTS
GH
为了在他“最后一次见到”时搜索买家,我从买家表查询到购物表,例如
SELECT
v.buyer,
MAX(s.timeArrived) AS LastSeen
FROM buyer_t AS b
INNER JOIN shop as s ON b.buyer = s.buyer
where
l.buyer = 'ABC' or l.buyer = 'CTS'
GROUP BY b.buyer;
很高兴知道 ABC 和 CTS 何时购物,但我如何获得“计费”和“付费”列