Jump to content

[SOLVED] CONCAT different between MySql 4 and 5 ?


RZero

Recommended Posts

Hi there I am running this simple query

$MySQL ="SELECT * FROM extensions WHERE dept ='7'";

$res1 = mysql_query($MySQL);

$ext = array();

$name = array();

 

while ($extension = mysql_fetch_array($res1)) {

$ext[] = $extension['ext'];

$name[] = $extension['Name'];

$startdate = 86400 * 7;

$mysql = "select concat(DAY(calldate) ,'/', MONTH(calldate),'/' ,YEAR(calldate)) as thisday, count(src) as calls from cdr where src in ('".implode("', '", $ext)."') and calldate > 604800 group by thisday"

Which when I run in MySql looks like this

select concat(DAY(calldate) ,'/', MONTH(calldate),'/' ,YEAR(calldate)) as thisday, count(src) as calls from cdr where src in ('554', '639', '646', '656', '675', '676', '681', '690', '691', '696', '580', '581', '566', '576', '586', '590', '574', '588', '518') and calldate > 604800 group by thisday

 

Which is correct but it only runs fine on one server running MySql 5 and I get this error

#1064 - You have an error in your SQL syntax.  Check the manual that corresponds to your MySQL server version for the right syntax to use near '( calldate ) , '/' , MONTH( calldate ) , '/' , YEAR( calldate )  when trying to run it on MySql 4

 

I have checked the SQL manuals and I can not see any difference between the two servers.  ???

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.