尝试创建一个mysql查询,在其中计算筛选器数据库的名称。成功,从某个时期取名字是主要目标。
$query = query("
SELECT count(CASE WHEN filter='冬越しする(現在地検索)' THEN 1 END) as filter,
count(CASE WHEN filter='開花期で選ぶ' THEN 1 END) as filter2,
count(CASE WHEN filter='日当たりで選ぶ' THEN 1 END) as filter3,
count(CASE WHEN filter='株幅で選ぶ' THEN 1 END) as filter4,
count(CASE WHEN filter='背丈で選ぶ' THEN 1 END) as filter5,
count(CASE WHEN filter='機能、タイプで選ぶ' THEN 1 END) as filter6,
count(CASE WHEN filter='ビギナーおすすめ' THEN 1 END) as filter7 FROM
filter_clicked WHERE filter_date < DATEADD(day, -30, GETDATE())");
最佳答案
您必须立即使用()-now()-interval 30天-您使用的是sql server函数
$query = query("
SELECT count(CASE WHEN filter='冬越しする(現在地検索)' THEN 1 END) as filter,
count(CASE WHEN filter='開花期で選ぶ' THEN 1 END) as filter2,
count(CASE WHEN filter='日当たりで選ぶ' THEN 1 END) as filter3,
count(CASE WHEN filter='株幅で選ぶ' THEN 1 END) as filter4,
count(CASE WHEN filter='背丈で選ぶ' THEN 1 END) as filter5,
count(CASE WHEN filter='機能、タイプで選ぶ' THEN 1 END) as filter6,
count(CASE WHEN filter='ビギナーおすすめ' THEN 1 END) as filter7 FROM
filter_clicked WHERE filter_date < date(now())-interval 30 day")
关于php - MySQL查询计数某些值,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/55488240/