$skuList = ProductSkuModel::selectRaw('product_skus.id as sku_id,
product_skus.code as code,
product_skus.wname as sku_name,
product_skus.stocks as stocks,
if(`product_skus`.`status`=1,\'上架\',\'下架\') as status,
brands.name as brand,
product_attributes.attribute_name as basic_attribute,
product_attributes.attribute_value_name as basic_attribute_name,
sku_attributes.attribute_name as price_attribute,
sku_attributes.attribute_value_name as price_attribute_name')
->leftJoin('product_attributes', 'product_skus.product_id',
'=', 'product_attributes.product_id')
->leftJoin('sku_attributes', 'product_skus.id',
'=', 'sku_attributes.sku_id')
->leftJoin('brands', 'product_skus.brand_id',
'=', 'brands.id')
->where('sku_attributes.status', 1)
->where('product_attributes.status', 1)
->get()->toArray();

laravel中连表查询的更多相关文章

  1. laravel中form表单,ajax传值没反应

    laravel中form表单,ajax传值没反应时,可能是令牌有问题. form中添加: {{csrf_token()}} ajax中添加: data: {'page': page, '_token' ...

  2. laravel中的表单请求类型和CSRF防护(六)

    laravel中为我们提供了绑定不同http请求类型的函数. Route::get('/test', function () {}); Route::post('/test', function () ...

  3. laravel 中with关联查询限定查询字段

    学习了下laravel5.6框架,果然很优雅,比如ActiveJieSuan model中作如下关联:(laravel模型关联关系可以查看https://laravelacademy.org/post ...

  4. Django中多表查询思路

    需求: 1.有一张文章表和一张评论表 2.两张表的关系是一对多 3.规则:若是有新评论,则将对应的文章置顶,若是有新文章则将新文章置顶. 思路: 在文章表中增加一个最后评论时间的字段.然后采用分组排序 ...

  5. sql 中多表查询-leetcode : Combine Two Tables

    因为对数据库的内容早都忘得差不多了,所以我的第一感觉是: select Person.FirstName, Person.LastName, Address.City from Person, Add ...

  6. 常用oracle中系统表查询语句

    sqlplus / as sysdbaSQL>select status from v$instance;1.查看最大连接数show parameter processes;2.查询oracle ...

  7. laravel中设置表单的方式,以及获取表单的提交的数据

  8. ACTION 中 单表查询语句 SQL写法

    JSP页面 <tr> <td class="STYLE1"> <div align="center"> // 单击事件 调用 ...

  9. laravel中,提交表单后给出提示例如添加成功,添加失败等等

    laravel中的表单插入,我想在表单插入成功后,可以像thinkphp一样可以有一个提示内容,上网Google,他们还是给出的方法就是 return redirect('/')->with(' ...

随机推荐

  1. Unity3D学习笔记(三十八):VR开发

    设备安装:HTC View   驱动安装:Steam - SteamVR 设备激活 Unity开发 下载安装开发包 Asset Store - SteamVR Plugin SteamVRDemo1- ...

  2. MongoDB集群配置笔记二(实战)

    单台mongodb配置文件: dbpath=/opt/mongodb/data logpath=/opt/mongodb/logs/mongodb.log logappend=true fork=tr ...

  3. sql server数据库自动备份

    SqlServer 数据库自动备份的两种解决方案 SQL Server中的角色(服务器级别和数据库级别角色) SqlServer服务器角色和数据库角色相关操作

  4. 洛谷P1679神奇的四次方数--DP

    原题请戳>>https://www.luogu.org/problem/show?pid=1679<< 题目描述 在你的帮助下,v神终于帮同学找到了最合适的大学,接下来就要通知 ...

  5. 5、lvs使用进阶(01)

    四层.七层负载均衡的区别  https://jaminzhang.github.io/lb/L4-L7-Load-Balancer-Difference/   netfilter/iptables简介 ...

  6. 51nod 1437 迈克步(单调栈)

    http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1437 题意: 思路: 单调栈题.求出以每个数为区间最大值的区间范围即可. ...

  7. android获取屏幕宽度和高度

    1. WindowManager wm = (WindowManager) getContext() .getSystemService(Context.WINDOW_SERVICE); int wi ...

  8. _itemmod_creation_enchant

    该表控制物品产生时自动获得随机附魔效果 comment  备注  entry  物品entry  slot  附魔位置1-5,这些位置都可以用来产生自带附魔效果  groupId  附魔组Id 对就_ ...

  9. P1547 Out of Hay

    传送门     练习 只是一个最小生成树的水题,拿来练练模板 AC代码: #include<iostream> #include<cstdio> #include<alg ...

  10. python的try finally (还真不简单)

    https://www.cnblogs.com/cotton/p/3785999.html def f(): try: print 1 return 1 finally: print 0 return ...