dpquu9206 2018-06-09 03:02 采纳率: 0%
浏览 45

总结表SQL的所有价格

how to sum the row of the price in my table here's my code.

$sql=mysql_query("SELECT sum(Price) * FROM reservations as A
    inner join service as B on A.Res_ser_ID = B.Ser_ID
    inner join personel as C on A.Res_per_ID = C.Per_ID
    where Res_cus_ID = '$userID' ");
  • 写回答

2条回答 默认 最新

  • dongxin1999 2018-06-09 03:10
    关注

    You need to upgrade to supported software such as mysqli_. PHP's mysql_ API has been unsupported for many years. Then you can use parameters -- a key to safe and effective use of SQL from applications.

    I think something like this (not using parameters):

    SELECT sum(s.Price) as sum_price
    FROM reservations r JOIN
         service s 
         ON r.Res_ser_ID = s.Ser_ID
    WHERE r.Res_cus_ID = '$userID';
    

    This assumes that the price comes from the service table.

    评论

报告相同问题?

悬赏问题

  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)