Jump to content

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?

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.