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 ();
thinkphp sql语句
最新推荐文章于 2025-04-27 09:29:34 发布