当前位置: 代码迷 >> SQL >> SQL语句查询时亟需选择主键
  详细解决方案

SQL语句查询时亟需选择主键

热度:106   发布时间:2016-05-05 11:07:11.0
SQL语句查询时需要选择主键

select tanhui_xiangmu_carbon.id, sum(carbonStore) from xm_mu_product, xm_user_tree, tanhui_xiangmu_carbon where xm_mu_product.tree_id=xm_user_tree.id and tanhui_xiangmu_carbon.id=xm_user_tree.carbon_id and tanhui_xiangmu_carbon.id='1

8' group by year having xm_mu_product.year in(select max(xm_jisuan_parameter.year) from xm_jisuan_parameter, xm_user_tree, xm_mu_product where xm_jisuan_parameter.tree_id=xm_user_tree.id and tanhui_xiangmu_carbon.id=xm_user_tree.carbon_id and tanhui_xiangmu_carbon.id='18')

加粗地方为主键,不添加时时会报错!

  相关解决方案