laravel中连表查询
$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中连表查询的更多相关文章
- laravel中form表单,ajax传值没反应
laravel中form表单,ajax传值没反应时,可能是令牌有问题. form中添加: {{csrf_token()}} ajax中添加: data: {'page': page, '_token' ...
- laravel中的表单请求类型和CSRF防护(六)
laravel中为我们提供了绑定不同http请求类型的函数. Route::get('/test', function () {}); Route::post('/test', function () ...
- laravel 中with关联查询限定查询字段
学习了下laravel5.6框架,果然很优雅,比如ActiveJieSuan model中作如下关联:(laravel模型关联关系可以查看https://laravelacademy.org/post ...
- Django中多表查询思路
需求: 1.有一张文章表和一张评论表 2.两张表的关系是一对多 3.规则:若是有新评论,则将对应的文章置顶,若是有新文章则将新文章置顶. 思路: 在文章表中增加一个最后评论时间的字段.然后采用分组排序 ...
- sql 中多表查询-leetcode : Combine Two Tables
因为对数据库的内容早都忘得差不多了,所以我的第一感觉是: select Person.FirstName, Person.LastName, Address.City from Person, Add ...
- 常用oracle中系统表查询语句
sqlplus / as sysdbaSQL>select status from v$instance;1.查看最大连接数show parameter processes;2.查询oracle ...
- laravel中设置表单的方式,以及获取表单的提交的数据
- ACTION 中 单表查询语句 SQL写法
JSP页面 <tr> <td class="STYLE1"> <div align="center"> // 单击事件 调用 ...
- laravel中,提交表单后给出提示例如添加成功,添加失败等等
laravel中的表单插入,我想在表单插入成功后,可以像thinkphp一样可以有一个提示内容,上网Google,他们还是给出的方法就是 return redirect('/')->with(' ...
随机推荐
- Dockerfile 收集
Dockerfile 收集 1.最基础的oracle-jdk FROM centos:7.2.1511 MAINTAINER hongdada "hongdaqi159505@gmail.c ...
- Sorting arrays in NumPy by column
https://stackoverflow.com/questions/2828059/sorting-arrays-in-numpy-by-column I suppose this works: ...
- ZOJ 3593 One Person Game(ExGcd + 最优解)题解
思路:题意转化为求 (ax+by=dis) || (ax+cy=dis) || (bx+cy=dis) 三个式子有解时的最小|x| + |y|.显然求解特解x,y直接用扩展欧几里得,那么怎么求|x| ...
- FAQ Flyway
https://flywaydb.org/documentation/faq What is the best strategy for dealing with hot fixes? You hav ...
- HDU 3507 Print Article(斜率优化)
显然的斜率优化模型 但是单调队列维护斜率单调性的时候出现了莫名的锅orz 代码 #include <cstdio> #include <algorithm> #include ...
- 一文读懂 深度强化学习算法 A3C (Actor-Critic Algorithm)
一文读懂 深度强化学习算法 A3C (Actor-Critic Algorithm) 2017-12-25 16:29:19 对于 A3C 算法感觉自己总是一知半解,现将其梳理一下,记录在此,也 ...
- java泛型的作用和好处
转载于:https://blog.csdn.net/u012760183/article/details/52092692 之前参加面试的时候遇到面试官问泛型的作用,只是说了大概自己的理解, 在此转载 ...
- s*s*r备用
遇见的问题 突然打不开 ip被墙 能ping 但是不能ssh 参考https://www.vultrcn.com/6.html
- React内三种函数的写法
以下提供三种React内函数的写法,都可以正常运行,有疑问可以留言 写法一:让函数内部的this指向这个类的实例,它是用bind实现的,bind的第一个参数表示context,就是this. //写 ...
- Java只给汉字转URLEncoder
public static String encode(String str, String charset) throws UnsupportedEncodingException { Patter ...