0

在我的应用程序中,我有一个存储为布尔值的值。在网格视图中显示时,如何将该布尔值更改为文本。

我有这个 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

我正在检索所有错误(0)的驾驶员评分。现在,当我将它显示到网格视图时,我想将布尔值 false 更改为不令人满意。

我怎样才能在sql查询中做到这一点?

4

2 回答 2

1

Booking.DriverRating -> 案例 Booking.DriverRating 当 0 时为 'Unsatisfactory' 否则 'Satisfactory' 以 'Booking.DriverRating' 结尾

于 2012-11-12T12:57:46.327 回答
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)
于 2012-11-12T13:00:15.760 回答