php - Select from 3 tables with calculating -


i try make query in mysql gets data 3 tables, , calculate in 2 tables. don't know how this.

i have in php code calculate "avage cost per click":

  1. get campaigns.

      select * campaigns; 
  2. get how many clicks campaign has:

    select sum(id) ialt2 aktivitet annonce_id = '@@campaign_id' group ip"); 
  3. get total revenure rows

    select sum(price) ialt money ad = '@@campaign_id' group id 

now can calculate "avage cost per click"

 "ialt / ialt2" = cpc 

then should say:

select * campaign order cpc desc limit 0,1 

select * campaigns c order (     (select sum(price) money ad = c.campaign_id)     /     (select sum(id) aktivitet annonce_id = c.campaign_id) )desc limit 0,1 

just guessing, think want this


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -