在我的应用程序中,我有一个值存储为布尔值。 在网格视图中显示时,如何将布尔值更改为文本。
我有这个sql
SELECT Driver.FirstName + Driver.LastName AS DriverName, Driver.PhoneNumber,
Booking.BookingId, Booking.DriverRating, Driver.CarId AS CarUsed
FROM Booking
INNER JOIN Driver ON Booking.DriverId = Driver.DriverId
WHERE Booking.DriverRating = 0
我正在检索所有驱动程序评级,即false(0)。现在当我将它显示到网格视图时,我想将布尔值false更改为不满意。
我如何在sql查询中执行此操作?
答案 0 :(得分:1)
Booking.DriverRating - >案例Booking.DriverRating为0然后'不满意'否则'满意'结束为'Booking.DriverRating'
答案 1 :(得分:1)
如何从服务器检索它作为字符串开始?
例如
SELECT Driver.FirstName + Driver.LastName AS DriverName, Driver.PhoneNumber, Booking.BookingId,
Case Booking.DriverRating When 0 then 'Unsatisfactory' else 'Satisfactory' end as DriverRating,
Driver.CarId AS CarUsed
FROM Booking
INNER JOIN Driver ON Booking.DriverId = Driver.DriverId
WHERE (Booking.DriverRating = 0)
或者在你的情况下,因为你已经在使用where子句:
SELECT Driver.FirstName + Driver.LastName AS DriverName, Driver.PhoneNumber, Booking.BookingId,
'Unsatisfactory' as DriverRating,
Driver.CarId AS CarUsed
FROM Booking INNER JOIN Driver ON Booking.DriverId = Driver.DriverId
WHERE (Booking.DriverRating = 0)