gpt4 book ai didi

php - 选择并计算字段

转载 作者:行者123 更新时间:2023-11-29 22:27:58 26 4
gpt4 key购买 nike

我想退回以下内容:

  • 数据库中“Peter”位于“users”列中的最后一个字段是什么?返回日期。
  • 用户“Peter”在列中列出的频率“用户”。返回一个整数。

这是我到目前为止所拥有的:

$user = 'Peter';
$myrows = $wpdb->get_row("SELECT users, date FROM yc_customers WHERE users = $user");

foreach ($myrows as $myrow) {
// Do something here
}

感谢任何帮助。

最佳答案

尝试:

 $myrows = $wpdb->get_row("SELECT users, MAX(date), COUNT(*) 
FROM yc_customers
WHERE users = '$user'
GROUP BY users");

关于php - 选择并计算字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30087353/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com