javascript - Codeigniter Join 如果值不为 NULL
问题描述
我想要代码,如果我找到了字段数据,那么我想将该特定数据加入另一个表。
$this->db->select('*');
$this->db->from('userprofile');
$this->db->where('userId', $userId);
$this->db->where('status', 1);
$this->db->join('bodytype', 'bodytype.bodyTypeId = userprofile.bodyType');
$this->db->join('children', 'children.childrenId = userprofile.children');
$this->db->join('ethnticity', 'ethnticity.ethnticityId = userprofile.ethnicity');
$this->db->join('smoke', 'smoke.smokeId = userprofile.smoke');
$this->db->join('drink', 'drink.drinkId = userprofile.drink');
$query = $this->db->get();
return $query->result();
如果我得到 userprofile.bodyType 然后 bodytype joinquery 运行。有什么办法来处理它?
解决方案
尝试 INNER JOIN :
$this->db->join('bodytype', 'bodytype.bodyTypeId = userprofile.bodyType','inner');
推荐阅读
- jms - 如何在 Wildfly 集群中配置 JMS 组处理?
- java - 使用外部分隔符逗号在 Java 中使用嵌套大括号拆分字符串
- amazon-web-services - 使用 ansible 限制 S3 同步的上传带宽
- sapui5 - SAP UI5 - 卡片 - 如何在卡片控件上触发 onclick,这将导致打开列表控件
- sql - SQL插入字符串
- sql-server - 如何在 T-SQL 中联合子查询
- python-3.x - getHeight 如何递归确定二叉树的高度?
- jmeter - 如何使用随机 csv 配置将 json 文件读入 jmeter
- wordpress - WooCommerce 批量产品价格更新
- python - 我想从我的数据框中获取原始价格