-1

我正在尝试获取唯一值,但我得到了以下语句的多个值。

SELECT bd.sessionkey, 
       bd.booking_id, 
       Concat(cs.name, ' ', cs.surname) AS name, 
       cs.phone, 
       cs.id, 
       pikuppoint, 
       droppoint, 
       bd.pickupdate, 
       bd.pickuptime, 
       bc.booking_id, 
       bc.paymenttype, 
       bc.pay, 
       bc.paydate, 
       bc.payment_status, 
       bp.booking_id, 
       bp.adultpassenger, 
       bp.childrenpassenger, 
       bp.babies, 
       bp.children_age, 
       bp.babies_age, 
       bp.totalpassenger, 
       bp.babies_seat, 
       bp.biglugage, 
       bp.mediumlugage, 
       bp.smalllugage, 
       b.order_id, 
       b.site, 
       b.transferdirection_id, 
       b.customer_id, 
       b.cartype, 
       b.specialrequirment, 
       b.bookingdate 
FROM   customerdetails cs, 
       bookingpassengers bp, 
       booking b, 
       bookingcost bc, 
       bookingdetails bd 
WHERE  bp.booking_id = bc.booking_id 
       AND bp.booking_id = b.order_id 
       AND b.order_id = bd.booking_id 
       AND b.order_id = bc.booking_id 
       AND bd.booking_id = bp.booking_id 
       AND cs.id = b.customer_id 
       AND bd.pickupdate BETWEEN Date_sub(Curdate(), INTERVAL 0 day) AND 
                                 Date_add(Curdate(), INTERVAL 1 day) 
ORDER  BY bd.pickupdate, 
          bd.pickuptime, 
          id 
LIMIT  0, 15 

任何帮助将不胜感激。

4

1 回答 1

0

您的 SELECT 语句只是选择符合您条件的所有值。

尝试使用 SELECT DISTINCT

http://www.w3schools.com/sql/sql_distinct.asp

于 2013-09-13T16:58:58.640 回答