Jump to content

Problem With TRIM BOTH?


mrhenniger

Recommended Posts

I have been trying to use TRIM for the first time.  I am havnig trouble with the BOTH option.  Here is how I have been assembling the command...

 

$commandPart1 = "SELECT Serial, Name, " .

    "TRIM(LEADING '.' FROM CONCAT(NameModelPrefix, '.', NameModel, NameModelSuffix)) AS NameMdl, " .

    "LENGTH(TRIM(LEADING '.' FROM CONCAT(ManufacturerModelPrefix, ManufacturerModel, ManufacturerModelSuffix))) AS Len " .

    "FROM AirframeVariant " .

    "WHERE FamilySN=" . $refFamilySN;

$commandPart2 = "SELECT Serial " .

    "TRIM(BOTH ' ' FROM CONCAT(Name, ' ', NameMdl)) AS Mdl, " .

    "LENGTH(TRIM(BOTH ' ' FROM CONCAT(Name, ' ', NameMdl))) AS Len " .

    "FROM (" . $commandPart1 . ") a1";

$commandPart3 = "SELECT Serial " .

    "FROM (" . $commandPart2 . ") a2 " .

    "WHERE Mdl LIKE \"%" . $refModel . "%\" " .

    "ORDER BY Len";

 

...which assembles as...

 

SELECT Serial FROM (SELECT Serial TRIM(BOTH ' ' FROM CONCAT(Name, ' ', NameMdl)) AS Mdl, LENGTH(TRIM(BOTH ' ' FROM CONCAT(Name, ' ', NameMdl))) AS Len FROM (SELECT Serial, Name, TRIM(LEADING '.' FROM CONCAT(NameModelPrefix, '.', NameModel, NameModelSuffix)) AS NameMdl, LENGTH(TRIM(LEADING '.' FROM CONCAT(ManufacturerModelPrefix, ManufacturerModel, ManufacturerModelSuffix))) AS Len FROM AirframeVariant WHERE FamilySN=3) a1) a2 WHERE Mdl LIKE "%Mustang IV%" ORDER BY Len

 

...but unfortunately produces this error...

 

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 'TRIM(BOTH ' ' FROM CONCAT(Name, ' ', NameMdl)) AS Mdl, LENGTH(TRIM(BOTH ' ' FROM' at line 1

 

I have been reading the online manuals, but I don't see what I am doing wrong.  Apparently my service provided uses MySQL 5.0.

 

Thanks in advance for any assistance you can provide.

 

Mike

 

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.