0

次のように、列を含む mySQL クエリを使用して tableadaptor を構築しようとしています。

if((`c`.`timed` > 0), 'Y', 'N') AS `Timed`,

これは、MySQL ワークベンチで実行すると機能しますが、VS2012 ではエラーが発生し、select ステートメントを生成できません。

私も使ってみました

case `c`.`timed` when 0 then 'Y' when 1 then 'N' end AS `Timed`,

成功しませんでした。

このクエリの書き方を教えてください。

ありがとう

完全なクエリ:

select 
    `c`.`callid` AS `callid`,
    concat(`cs`.`firstname`, ' ', `cs`.`lastname`) AS `Customer`,
    `c`.`postcode` AS `postcode`,
    `c`.`type` AS `type`,
if((`c`.`timed` > 0), 'Y', 'N') AS `Timed`,   `c`.`calldate` AS `calldate`,
`c`.`notes` AS `notes`,
    `c`.`driver` AS `Driver`
from
    (((`quick-quote-2`.`call` `c`
    left join `quick-quote-2`.`driver` `d` ON ((`c`.`driver` = `d`.`driverid`)))
    left join `quick-quote-2`.`booking` `b` ON ((`c`.`booking` = `b`.`bookingid`)))
    left join `quick-quote-2`.`customer` `cs` ON ((`b`.`customer` =  `cs`.`customerid`)))
where
    (`c`.`canx` = 0)

エラー:

Error in list of function arguments: '>' not recognised
unable to parse query text
4

1 に答える 1

0

VS とIF()関数がエラーの原因であるかどうかはわかりませんが、いつでもCASE式を使用できます。これは同等です:

CASE WHEN `c`.`timed` > 0 THEN 'Y' ELSE 'N' END AS `Timed`,
于 2013-01-27T21:10:42.357 に答える