Laravel雄辩的UNION查询,额外的列addSelect()不起作用

时间:2018-03-14 14:21:55

标签: mysql sql laravel orm laravel-eloquent

$first = DB::table('users')
        ->select("id","full_name")
        **->addSelect("user_table AS tableN")**
        ->where("full_name", "LIKE", "%a%");

    $users = DB::table("medical_specialties")
        ->select("id","name")
        **->addSelect("medical_speciality_table As tableN")**
        ->where("NAME", "LIKE", "%a%")
        ->union($first)
        ->toSql();

这是laravel Eloquent查询,其中addSelect方法应该在结果集“Type”中创建新列,其中将包含一些文本即表名但它会给出此错误 enter image description here

0 个答案:

没有答案