gpt4 book ai didi

mysql - Mysql中Join表数据重复

转载 作者:行者123 更新时间:2023-11-29 15:23:21 26 4
gpt4 key购买 nike

我创建了两个表busbook座位。当我连接两个重复的表数据时,我不知道为什么。

SELECT seats.busno,
seats.seats,
busbook.status,
busbook.customer,
busbook.mobile,
seats.date
FROM seats
Left JOIN busbook ON seats.busno=busbook.busno

这是我得到的输出:

busno  seats     status     customer         mobile    date
91000 1 Booked ss 11 2019-12-06
91000 2 Booked ss 11 2019-12-06
91000 3 Booked ss 11 2019-12-06
91000 4 Booked ss 11 2019-12-06
91000 5 Booked ss 11 2019-12-06
91000 6 Booked ss 11 2019-12-06
91000 7 Booked ss 11 2019-12-06
91000 8 Booked ss 11 2019-12-06
91000 9 Booked ss 11 2019-12-06
91000 10 Booked ss 11 2019-12-06

座位表:

id    busno   seats       date
1 91000 1 2019-12-06
2 91000 2 2019-12-06
3 91000 3 2019-12-06
4 91000 4 2019-12-06
5 91000 5 2019-12-06
6 91000 6 2019-12-06
7 91000 7 2019-12-06
8 91000 8 2019-12-06
9 91000 9 2019-12-06
10 91000 10 2019-12-06
11 91000 11 2019-12-06
12 91000 12 2019-12-06

busbook表:

id  busno   seat     status       customer       mobile        date
2 91000 1 Booked ss 11 2019-12-06
3 91000 19 Booked dd 22 2019-12-06

最佳答案

怎么样

SELECT seats.busno, seats.seats,busbook.status, busbook.customer,busbook.mobile,seats.date FROM seats 
Left JOIN busbook ON seats.busno=busbook.busno
AND seats.seats = busbook.seat

我想这取决于通过 Seats.id 或 Seats.seats 加入的具体方案

关于mysql - Mysql中Join表数据重复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59211817/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com