mysql从逗号分隔值中获取计数

时间:2018-03-09 05:52:14

标签: php mysql

select `announcement`.`id` as `announcement_id`, `announcement`.`user_id`, `announcement`.`announcement_type`, `announcement`.`announcement_name`, `announcement`.`announcement_description`, `announcement`.`image`, `announcement`.`announcement_date`, `announcement`.`announcement_time`, `announcement`.`status`, `announcement`.`announcement_location` as `venue`, `users`.`name` as `username`, `users`.`country`, `users`.`state`, `countries`.`name` as `countryName`, `states`.`name` as `stateName`, `like_share.SUM(LENGTH(like_share`.`liked_by) - LENGTH(REPLACE(like_share`.`liked_by, ",", "")) + 1)` as `totalike` 
from `announcement` 
inner join `users` on `users`.`id` = `announcement`.`user_id` inner join `countries` on `users`.`country` = `countries`.`id` inner join `states` on `users`.`state` = `states`.`id` 
left join `like_share` on `announcement`.`id` = `like_share`.`announcement_id` 
where `announcement`.`status` = 0 and `announcement`.`announcement_date` >= 2018-03-09 order by `announcement`.`created_at` desc

我收到以下错误:

#1054 - Unknown column 'like_share.SUM(LENGTH(like_share.liked_by) - LENGTH(REPLACE(like_share.liked_by, ",", "")) + 1)' in 'field list'

0 个答案:

没有答案