thinkphp sql语句

来源:互联网 发布:mac怎么转换音频格式 编辑:程序博客网 时间:2024/04/30 03:41
tb_user_organization (userid,organizationid);//组织用户表tb_user(id,name,sex);//用户表查询与某个用户在同一个组织内的所有用户$demo=M("table");$list=$demo->table('tb_user_organization a,tb_user b')->where("a.userid=b.id and a.organizationid=用户id")->field('b.*')->order('a.userid desc' )->limit(5)->select();$demo->getLastSql(); //打印一下SQL语句,查看一下table()中的表明一定要全,前缀也要放 表后面跟别名 //模糊查询$result1=M('table')->table('tb_user a,tb_business b')->where("a.tb_username like '%{$_GET['key']}%'and a.tb_id = b.tb_uid and a.tb_level=1")->order('a.tb_id desc')->limit ($Page->firstRow . ',' . $Page->listRows )->select ();
0 0
原创粉丝点击