Jump to content

convert sql query to php query


eloginko

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.