mysql - 将以下 MySQL 查询转换为 codeigniter

标签 mysql codeigniter

如何在 codeigniter 中编写此查询

SELECT U.username,U.user_id
FROM storylikes S, user U
WHERE U.user_id=S.user_id_fk AND S.user_id_fk='$id'

最佳答案

试试这个:

$this->db->select('u.username, u.user_id');
db->where('u. user_id = s.user_id_fk');
$this->db->where('s.user_id_fk = '.$id);
$query = $this->db->get('storylikes s, user u');

使用 $your_variable = $query->result(); 作为结果

关于mysql - 将以下 MySQL 查询转换为 codeigniter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42106665/

相关文章:

java - MySQL 从 XML 文件中插入数据

c# - 没有类型为 'IEnumerable<SelectListItem>' 的 ViewData 项具有键specialityId'。'。

php - 如何组织数据库中的表?

php - Ion Auth update_user() 不更新用户

php - 当字符串包含 & 符号时,在值末尾添加额外的分号

php - CodeIgniter 从 Controller 返回数据

mysql - 尝试根据第二个表查询的连接结果进行 MySQL Sum

auto-increment - 每个表有多个 AutoIncrement

codeigniter - 从上传的视频中获取图像 codeigniter

php - 从数据库中选择包含部分变量的行