left join 和 left outer join 的区别
web SQL 2017-09-19 2331 0
关于本站

“最难不过坚持”

本人承接扒站仿站,php网站维护,病毒查杀,网站编辑,网站改版,html制作

有需要网站维护,改版,病毒查杀,网站编辑,网站备案,html制作等相关的工作可以联系我。
本人有多年相关工作经验,也可提供免费咨询,交个朋友。
有需要探讨问题的朋友,也可以加我微信,共同探讨!
微信:15011482830 QQ:408917339

6442432 2612 39
最新评论
https://jueru.net/
评 留言
:weixiao:
评 留言
:shuijiao: :weiqu: :zhenbang: :leng:
评 留言
:yiwen: :yiwen: :yiwen: :yiwen:
评 EasySass: could not generate CSS file. See Output panel for details.
这个业务逻辑多少都有点奇怪了,阅读浏览次数增值在新闻详情页的控制器方法里setInc,这怎么还写进模型事件里了。如果非要用onAfterRead也可以,把新闻文章的内容单独分出来一个news_content表,然后把它和news做关联,然后给news_content表的onAfterRead事件做增值处理,这样点进新闻页内查询到文章内容时才会触发它。
评 TP6模型事件-查询后onAfterRead不好用
文章标签更多
ThinkPHP (254)
Mysql (58)
DedeCms (33)
jQuery (67)
证件照 (1)
setInc (4)
setDec (4)
onclick (5)
打开边栏(ESC) 关闭边栏(ESC)
通俗的讲:  
  A   left   join   B   的连接的记录数与A表的记录数同  
  A   right   join   B   的连接的记录数与B表的记录数同    
  A   left   join   B   等价B   right   join   A     
   
  table   A:  
Field_K,   Field_A  
  1                       a  
  3                       b  
  4                       c  
   
  table   B:  
  Field_K,   Field_B  
  1                       x  
  2                       y  
  4                       z  
   
  select   a.Field_K,   a.Field_A,   b.Field_K,   b.Field_B  
  from   a   left   join   b   on   a.Field_K=b.Field_K  
   
  Field_K         Field_A         Field_K         Field_B          
  ----------   ----------   ----------   ----------    
  1                     a                     1                     x                    
  3                     b                     NULL               NULL  
  4                     c                     4                     z                    
   
  select   a.Field_K,   a.Field_A,   b.Field_K,   b.Field_B  
  from   a   right   join   b   on   a.Field_K=b.Field_K  
   
  Field_K         Field_A         Field_K         Field_B          
  ----------   ----------   ----------   ----------    
  1                     a                     1                     x                    
  NULL               NULL               2                     y                    

  4                     c                     4                     z  


举个例子:  
  假设a表和b表的数据是这样的。  
  a                         b    
  id     name  id     stock   
  1  a             1         15  
  2         b             2         50  
  3         c                  
   
  select   *   from   a   inner   join   b   on   a.id=b.id  
  这个语法是连接查询中的内连接,它产生的结果是  
  两个表相匹配的记录出现在结果列表中。  
  根据上面的表,出现的结果是这样的  
  a.id     name     b.id     stock  
  1       a             1         15  
  2             b             2         50  
  ----------------------------  
  select   *   from   a,b   where   a.id=b.id  
  这个语法是内连接的另外一种写法,其执行结果与inner   join   一样  
   
  --------------------------------    
   
  select   *   from   a   left/right   join   b   on   a.id=b.id  
  这个是外连接语法中的左外连接或右外连接  
  如果是左外连接的话,它将显示a表的所有记录,  
  select   a.*,b.*   from   a   left   join   b   on   a.id=b.id  
  查询的结果是这样的:  
  a.id     name     b.id     stock  
  1         a         1             15  
  2               b         2             50  
  3               c       null         null   
  --------------------------------------------  
  如果是右外连接的话,它将显示b表的所有记录,  
  select   a.*,b.*   from   a   right   join   b   on   a.id=b.id  
  查询的结果是这样的:  
  a.id     name     b.id     stock  
  1         a         1             15  
  2               b         2             50   

--

select   a.*,b.*   from   a   left   join   b   on   a.k   =   b.k    
  select   a.*,b.*   from   a   left   outer   join   b   on   a.k   =b.k  
  ----------上面两种一样left   join是left   outer   join的简写  
  select   a.*,b.*   from   a   left   inner   join   b   on   a.k   =   b.k    
  没有这种写法,错误的语句.

--

在你要使用多个left   join的时候  
  比如说10个  
  我们把10个全都写成left   join的形式  
  然后再SQL让他自动运行一下,它会把最后一次出现的left   join变成left   outer   join  
  所以依此推理,最后一个left   join会以left   outer   join的形式存在  
  当然,不管变不变对结果的显示没有任何影响  
  希望我的实验能对你有所帮助   

版权声明:本篇文章来源于网络。 来源链接

相关推荐
Mysql 使用AVG聚合函数时,保留两位小数的方法
SQL | 2020-09-28 5170
关于查询最高分、最低分和平均分的 SQL 语句时突然想把 AVG 函数的保留小数设置为两位 SELECT MAX(student_result) AS 最高分,MIN(student_result) AS 最低分,CAST(AVG(student_result) AS DECIMAL(10,2)) AS 平均分 FROM resu...
sql语句统计每天、每月、每年的数据
SQL | 2017-09-18 4380
1、每年 select year(ordertime) 年, sum(Total) 销售合计 from 订单表 group by year(ordertime) 2、每月 select year(ordertime) 年, month(ordertime) 月, sum(Total) 销售合计 from 订单表 group by yea...
评论:0条
评论加载中...
发表评论