NorthWest
11-09-2005, 01:43 PM
This query is not wanting to work for me. Can you guys take a look and see if you see the problem.
Thanks
$query2 = "SELECT sid, day, source, sum(custData.approved) AS sumApproved from custData where source = $row[company] group by day order by day desc'";
Burhan
11-09-2005, 01:55 PM
Please don't ask a question such as 'it doesn't work - what is wrong'. What do you mean it doesn't work? Its sitting on the couch all day watching TV and eating all your food? Learn how to ask questions (http://www.catb.org/~esr/faqs/smart-questions.html).
For one, you have a problem with a renegade '
desc'"
Second, you probably want to quote the value of $row['company']
maro25
11-09-2005, 04:01 PM
I guess your main sql problem here is that day is a reserved word
folsom
11-09-2005, 06:05 PM
SELECT sid
, day
, source
, sum(custData.approved) AS sumApproved
from custData
where source = $row[company]
group by day
order by day desc'
Like the rude community guide pointed out, the single quote at the end could be a problem.
The group by is only on day, and you only have an aggregate on custData.approved, so what is to be done with source and sid. You will either have to make them a group by or use an aggregate on them.
innova
11-09-2005, 10:44 PM
Like the rude community guide pointed out,
Dont make the mistake of assuming he was rude. He is very smart (read some of his other posts in this forum) and was trying to help the poster ask more intelligent questions.
hiryuu
11-10-2005, 01:50 AM
Like the rude community guide pointed out, the single quote at the end could be a problem.
Harsh, perhaps, but not rude. Rude is expecting others to work for you, for free, without doing even the most basic diagnostics on your own. If they choose to help you, they need to spend time determining what you could easily report from the get-go, which means they can help fewer people, and those other people must wait longer.
I also love problem reports that flat-out lie because they don't want to look like idiots. Of course, we usually find out what they did while determining the issue, anyway, so we're less than amused by them wasting hours of our time dragging us along the wrong trail.
My favorite ticket this week:
User: umm i put in my ftp and all my login in info and it still doesnt make why?
Me: Are you getting an error message of any sort?
User: yes i am
Even if you don't want to do actual error handling in your script, when a query doesn't work, echo it (so all the variables are replaced), and run the query in whatever client program the database offers. That reminds me -- he didn't even mention what SQL database he's using. For instance, non-aggregate fields, such as sid and source, are legal in MySQL, but not in other databases. Similarly, day may be reserved in MySQL, but not other servers.