zoukankan      html  css  js  c++  java
  • PHP开发之THINKPHP多表联合查询操作的三中方法

    联合查询
            1、原生查询
            $sql =$sql='select p.product_name,z.message as zmessage,z.rdtime,r.message,r.rdtime from wsd_product as p,wsd_product_zixun as z,wsd_product_zixun_reply as r where p.id=z.lipin_id and z.id=r.zixun_id order by z.rdtime';
            $list = $Form->query($sql);
            2、join() 两表查询
            $list = $Form->join('think_sort ON think_form.sort_id = think_sort.sort_id' )->select();
            3、join() 多表查询
            $list = $Form->join('think_sort ON think_form.sort_id = think_sort.sort_id' )->join('think_brand ON think_form.brand_id = think_brand.brand_id' )->select();
            4、table()
     $list = $user->table('user_status stats, user_profile profile')->where('stats.id = profile.typeid')->field('stats.id as id, stats.display as display, profile.title as title,profile.content as content')->order('stats.id desc' )->select();

  • 相关阅读:
    hdu 1527威佐夫博弈
    hdu 1506
    hdu 1878 欧拉回路
    欧拉回路知识
    hdu 2545 并查集 树上战争
    hdu 2594 kmp
    hdu 1867 kmp匹配
    hdu 2844 多重背包二进制优化
    hdu 4006
    1047
  • 原文地址:https://www.cnblogs.com/xiaofeng028/p/3545664.html
Copyright © 2011-2022 走看看