Microsoft
Software
Hardware
Network
Question : Need assistance with MYSQL PHP output query
Hi,
I have an online ordering system which basically uses two tables, these are called:
site_users - this table contains registration details when the customer registers on my website, this also produces a user_id field which is unique to the customer.
ordering - this contains all the online ordering information, including a field called total which stores each individual online order amount.
What i need to do is generate a report which will display all the customer unique, so if they have ordered multiple times they only appear once, but their total is the total of ALL orders...
The code I have so far is:
$result = mysql_query("
SELECT
`ordering`.`user_id`,`orde
ring`.`fir
st_name`, `ordering`.`last_name`, `ordering`.`total`,
(SELECT
sum(`ordering`.`total`)
FROM
`ordering`
) AS `total`
FROM
`ordering`
ORDER BY `total` DESC
;");
However this outputs all the rows, and the total of ALL orders is the same in each total field.
Can anybody help me for 500 points?
Thanks
Answer : Need assistance with MYSQL PHP output query
Sorry slight correction,
$result = mysql_query("
SELECT
`ordering`.`user_id`,`orde
ring`.`fir
st_name`, `ordering`.`last_name`, `ordering`.`total`,
sum(`ordering`.`total`) as `total`
FROM
`ordering`
GROUP BY `ordering`.`user_id
ORDER BY `total` DESC
;");
Random Solutions
change sched task pw via command line
How to Populate a ListBox Control with Values from an Access Database Table
Oracle packages
what is most cost effective way to backup windows 2008 sbs
Create linked server from MS Sql to oracle server
Outlook 2007 Continually asks for an Exchange Server password
VMware ESXI help
creating image using coldfusion
accessing exchange 2003 through an iphone
Gmail Like File Upload