Jump to content

Recommended Posts

is there a need to give the tables aliases??

 

this is what I have in my sql statement

$qx = "SELECT roster.handle AS 'name', roster.real_name AS 'rname', ";
$qx .= "EXTRACT(YEAR FROM servpay.paydate) AS 'YEAR', ";
$qx .= "SUM(IF(servpay.paymonth = 1, servpay.amount, 0)) AS 'JANUARY', ";
$qx .= "SUM(IF(servpay.paymonth = 2, servpay.amount, 0)) AS 'FEBRUARY', ";
$qx .= "SUM(IF(servpay.paymonth = 3, servpay.amount, 0)) AS 'MARCH', ";
$qx .= "SUM(IF(servpay.paymonth = 4, servpay.amount, 0)) AS 'APRIL', ";
$qx .= "SUM(IF(servpay.paymonth = 5, servpay.amount, 0)) AS 'MAY', ";
$qx .= "SUM(IF(servpay.paymonth = 6, servpay.amount, 0)) AS 'JUNE', ";
$qx .= "SUM(IF(servpay.paymonth = 7, servpay.amount, 0)) AS 'JULY', ";
$qx .= "SUM(IF(servpay.paymonth = 8, servpay.amount, 0)) AS 'AUGUST', ";
$qx .= "SUM(IF(servpay.paymonth = 9, servpay.amount, 0)) AS 'SEPTEMBER', ";
$qx .= "SUM(IF(servpay.paymonth = 10, servpay.amount, 0)) AS 'OCTOBER', ";
$qx .= "SUM(IF(servpay.paymonth = 11, servpay.amount, 0)) AS 'NOVEMBER', ";
$qx .= "SUM(IF(servpay.paymonth = 12, servpay.amount, 0)) AS 'DECEMBER' ";
$qx .= "FROM roster LEFT JOIN servpay on roster.id=servpay.playid ";
$qx .= "WHERE roster.title= 'OWNER' ";
$qx .= "GROUP BY YEAR ";
$qx .= "ORDER BY roster.id ";

 

I have it being grouped by year but what happens when I insert a person for the year 2006 everyone's name goes away accept the one person that has paid for 2006.

Link to comment
https://forums.phpfreaks.com/topic/2558-joins/#findComment-8492
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.