【发布时间】:2021-01-19 22:54:22
【问题描述】:
以下是我的查询;
select "column1", "desc", if r_id = P then Y else
'N' endif As is_selected from "other" where
"rtype" = D_STATUS
下面是我的查询生成器函数,
DB::table('other')
->select('r_id', 'description', DB::raw("if r_id ='P' then 'Y' else 'N' endif As is_selected")) //Error
->where('rtype', '=', $strType )
->get();
这里出现错误;
未找到“Y”列。
我想在查询中的所有静态字符串值中添加单引号而不是双引号。我该怎么做?
【问题讨论】:
-
是的,我只需要在 Y 列和 N 列周围添加单引号。你能告诉我该怎么做吗? @KamleshPaul
-
没有反引号键不起作用@KamleshPaul
-
我认为您的代码是正确的,因为错误提示
Column "Y" not found表示表中此列不存在 -
不,我的查询工作正常。这个查询只是缺少围绕“Y”的单引号@KamleshPaul
标签: php laravel laravel-5 laravel-query-builder