join关联表查询时,查询字段前面加上表名更高效
SELECT
`nft_publish`.`id`,
`nft_publish`.`author`,
`nft_publish`.`nft_name` AS `name`,
`nft_publish`.`display_url`,
`nft_publish`.`publish_count` AS `total_count`,
`nft_publish`.`sell_status`,
`nft_publish`.`sell_price` AS `price`,
`nft_publish`.`favorite`,
count(
IF
( nfts.STATUS = 0, nfts.id, NULL )) AS rest_count
FROM
`nft_publish`
LEFT JOIN `nfts` ON `nfts`.`nft_publish_id` = `nft_publish`.`id`
WHERE
`nft_publish`.`task_status` = 7
GROUP BY
`nft_publish`.`id`
HAVING
`rest_count` > 0
ORDER BY
`nft_publish`.`id` DESC
LIMIT 20 OFFSET 0