dongyisa6254 2017-04-17 11:35
浏览 40
已采纳

加入查询问题 - codeigniter

I have 2 tables tb_user_group and tb_user_follow_group i want to join this table in my style

tb_user_group

enter image description here

tb_user_follow_group

Group Follow Image

i want all records from tb_user_follow_group where tb_user_follow_group.group_id match with tb_user_group.id and is_follow='accept' also include tb_user_group.id = 1 and get all the fields of this two table.

not necessary answer in CodeIgniter Syntax post simple query also

This is my try query

$this->db->select('tb_user_follow_group.*,tb_user_group.*');
$this->db->from('tb_user_group');
$this->db->join('tb_user_follow_group', 'tb_user_group.id = tb_user_follow_group.group_id', 'left inner'); 
$query = $this->db->get();
return $query->result();
  • 写回答

1条回答 默认 最新

  • dsvf46980 2017-04-17 11:49
    关注

    try this but not tested

      select ug.* from tb_user_group ug LEFT JOIN tb_user_follow_group ufg ON ug.id = ufg.group_id WHERE ufg.is_follow='accept' OR ug.user_id='".$user_id."' GROUP BY ug.id;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?