Mysql查询不显示所有数据

标签 mysql

多表查询:

select * from bonlivraison,categorie,fourniture where bonlivraison.id_bl=fourniture.id_bl and fourniture.id_categorie=categorie.id_categorie

结果:219 行

单表查询:

select * from fourniture

结果:263 行

我希望第一个查询得到 263 行

最佳答案

使用左连接并从表 fourniture 开始

select * from fourniture 
left join categorie on fourniture.id_categorie=categorie.id_categorie 
left join  bonlivraison on bonlivraison.id_bl=fourniture.id_bl 

您的查询仅显示表 bonlivraison 中的记录,该记录在其他两个表中都有相关条目。

关于Mysql查询不显示所有数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39245214/

相关文章:

Mysql Date 在 where 子句中?

c# - 将字节数组转换为 System.Drawing.Image 时出错

php - "cannot connect using the old insecure authentication"但我没有旧密码?

mysql - 多段线无法绑定(bind)

php - 如何在 laravel 中使用 sql NOW( ) 函数

mysql - 如何在mysql中将日期时间分组为3小时的间隔

mysql - MySQL 查询中 EXPLAIN、count(1) 和表内容之间的差异

java - 加载驱动类 com.mysql.jdbc.Driver 失败

mysql - 如何找到最宽的租金价格区间?

php - 如何检查数组中是否存在给定的键或索引?