MySQL Forums
Forum List  »  Newbie

Re: SQL for CONCAT and remove character from certain columns
Posted by: Phillip Ward
Date: March 14, 2018 05:57AM

Quote

CASE
WHEN doc_type = "A01" THEN doc_no=LEFT(doc_no, LENGTH(doc_no)-4)
END

Very close, but not quite.

This translates into English as:

When the value of the field `doc_type` is "A01" then return the result of the expression ...
CASE 
doc_no = LEFT( doc_no, LENGTH( doc_no ) - 4 )
END

which, in turn, translates into English as :

Return TRUE if the field `doc_no` is the value of `doc_no` without the last four characters, or FALSE otherwise.

Simple fix:

CASE
WHEN doc_type = "A01" THEN LEFT(doc_no, LENGTH(doc_no)-4) 
END AS doc_no

Regards, Phill W.

Options: ReplyQuote


Subject
Written By
Posted
Re: SQL for CONCAT and remove character from certain columns
March 14, 2018 05:57AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.