Jump to content

How to SUM column named 'int'


msaz87

Recommended Posts

Hey all,

 

I'm working on some code made by a different, sloppier programmer who named a column in a DB 'int' -- which I know is a mysql reserved word. To change the column would take a lot of effort in finding its references in some other pages, so I figured I would see if there is a way to SUM this column. Doing "SUM(int)" errors and while "SUM('int')" works, I can't seem to get it to then output the results like normal (IE: $row['SUM(int)'])...

 

Any help is greatly appreciated -- thanks!

Link to comment
https://forums.phpfreaks.com/topic/193183-how-to-sum-column-named-int/
Share on other sites

If SUM('int') is working the in SQL query give alias name like  "SUM('int') AS cnt" and use it in $row['cnt']

 

That doesn't seem to work...

 

My query is as shown:

 


								$stats_query	= "	SELECT 
											SUM(td_pass), 
											SUM(int_pass), 
											SUM(td), 
											SUM(sacks), 
											SUM(int_d),
											SUM('int') AS exp 
											FROM XXX 
											WHERE player_id 	= '$player_id' 
											AND week		= '$week'";

 

And the echo:

 

	<?php echo $row['exp']; ?>

 

But instead of the SUM, it spits out all 0's... any ideas?

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.