【发布时间】:2015-09-14 04:11:30
【问题描述】:
select tbc.ID,tbc.Booking_reference,
concat(tbc.PickupDate , tbc.pickuptime) as PickupTime ,
(select master_package
from Tblmasterpackage
where package_id =tbc.BookingType) as Booking,
concat('Hello42 ', tbc.DeviceType) as Partner,concat( tbc.UserName , tbc.MobileNo ) as ClientName,
tbc.DropArea as droparea,
tbc.PickupArea as departure,
tbc.`Status`
from tblcabbooking tbc
inner join tbldriver td
on tbc.pickup=td.uid
inner join Tblmasterpackage tmp
on tmp.package_id=tbc.BookingType
where tbc.Bookingdate >= FromDate AND tbc.Bookingdate <= Todate
when IF CallerID is not null
THEN
and tbc.MobileNo=CallerID
END IF
when IF book_ref is not null
THEN
and tbc.Booking_reference=book_ref
END IF
when IF vehicle_number is not null
THEN
and td.VehicleRegistrationNo=vehicle_number
END IF
when IF vehicle_Driver is not null
THEN
and td.FirstName=vehicle_Driver
END IF
when IF PartnerType='Android Booking'
then
and tbc.DeviceType='ANDROID'
END IF
when IF PartnerType='Web Booking'
THEN
and tbc.DeviceType='WEB'
END IF
when IF PartnerType='Call Center Booking'
THEN
and tbc.DeviceType='0'
END IF
when IF PartnerType='All Booking'
THEN
END IF
order by ID desc limit limit_check,limite_off;
【问题讨论】:
-
你忘了问问题
-
请说明在 where case 中如何使用 null 值
-
我们使用七个值字段进行查询,因此在某些情况下某些值将为空,因此如何处理在 mysql 过程中使用空值的情况
标签: mysql database conditional