mysql - Does COUNT() run twice? -
i've code:
"select post_id, count(post_id) number_of_votes, (sum(vote) / count(post_id)) result " . log_table . " , $wpdb->posts p post_id = p.id , p.post_status = 'publish' group post_id having count(post_id) >= 2 order result desc, count(post_id) desc limit 10 "
i'd know if count used in first row run twice?
edit: run twice mean if acces table twice
best regards, dario
unless using subqueries of below form,table accessed once(if meant count, accessed twice),so count calculated once , used everywhere
select id,(select min(id) table1 t2 t1.id=t2.id)b table1 t1
Comments
Post a Comment