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.  ???

Link to comment
Share on other sites

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.