切换风格

Wizard Sky California Sunset glow Black Cloud Beige Dragon Lavender NewYear City Snow Flowers London
收藏本站XSS平台字符串转换jsfuck
php中跨表联合查询mysql中的as是什么意思以及用法[复制链接]
发表于 2012-11-8 16:10:35 | 显示全部楼层 |!read_mode!
参考
http://blog.csdn.net/zhuche110/article/details/2576123

例如:
  1.    //此分类下所有课程中涉及到的软件id
  2.    $query = DB::query("SELECT cid FROM ".DB::table('peixun_course_catid')." where catid = '$catid' order by displayorder desc ");
  3.     while($all_cid_of_catid = DB::fetch($query)) {
  4.                  $all_cids_of_catid[] = $all_cid_of_catid[cid];
  5.    }
  6.    $all_cids_of_catid_str = implode(',',$all_cids_of_catid);
  7.    $query = DB::query("SELECT softid FROM ".DB::table('peixun_course')." where cid in($all_cids_of_catid_str)  order by pubtime desc ");
  8.    while($all_soft_of_coures = DB::fetch($query)) {
  9.                 $all_softs_of_coures[] = $all_soft_of_coures;
  10.    }
复制代码
用as后可精简为
  1.    $query = DB::query("SELECT distinct course.softid from ".DB::table('peixun_course_catid')." AS course_catid , ".DB::table('peixun_course')." AS course
  2.                                    where  course_catid.cid = course.cid and course_catid.catid = '$catid' ");
  3.     while($all_soft_of_coures = DB::fetch($query)) {
  4.                $all_softs_of_coures[] = $all_soft_of_coures;
  5.     }
复制代码

distinct 是指去重复
操千曲而后晓声,观千剑而后识器。

代码区

GMT+8, 2020-10-25 07:17

Powered by Discuz! X2

© 2001-2018 Comsenz Inc.

回顶部