Jump to content

Recommended Posts

I have a table called

 

tb_applicants with fields 'id','aic','name','total'

 

This query total all the total of applicant with same aic field value and divide it with 7 and save the average score to a new table called:

 

fapptotal with field 'id','aic','name','ftotal'

 

My problem is i have the mysql query for it but i dont know how to use it in php..can anyone help me convert my query to php query.

 

here is my query:

 

INSERT INTO fapptotal (id,aic,name,ftotal)

SELECT DISTINCT

t.id

,t.aic

,t.name

,(SELECT SUM(t2.total) FROM tb_applicants t2 WHERE t2.aic = t.aic)/7 thissum

FROM tb_applicants t

GROUP BY name HAVING COUNT(DISTINCT aic)=1

Link to comment
https://forums.phpfreaks.com/topic/285649-convert-sql-query-to-php-query/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.