mysql - 如何在我的条件下使用内连接

标签 mysql sql

我有两张这样的 table

   c_ID    name
    ---   ------
    7      a
    6      a
    5      a
    4      d

并且

   c_ID    photo
  -----   ------
    7       1
    6       1
    5       0
    4       1

如何选择名称为 a 且照片为 1 的记录?

谢谢

最佳答案

select *  /*TODO: Add specific column(s) you want here*/
from   table1
       join table2
         on table1.c_ID = table2.c_ID
where  table1.name = 'a'
       and table2.photo = 1  

关于mysql - 如何在我的条件下使用内连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5449488/

相关文章:

php - 使用 codeigniter 跨多个表进行复杂的 where/join 语句

mysql - sails.js 查询表列内的 json 对象

javascript - 需要解决这个 javascript 编码问题

mysql - SQL 重复结果

sql - 根据最大日期和分组依据更新列

mysql - 如何从 MySQL 中的日期时间中减去小时数?

php - 无法接收 PHP/HTML 中的 POST 结果

sql - 这可以用sql吗?

MySQL - 查询多个表和关系

php - MySQL通配符过滤特殊字符使用LIKE