I am trying to concatenate two fields in a query, but if one of the tow is empty, it is not returning anything.
Here is what I am using:
CONCAT( "OADDRESS1", "OADDRESS2" )
When OADDRESS2 is empty, it is returning an empty field.
How can I bring just OADDRESS1 when OADDRESS2 is empty?
Thanks!
Concat with null string
Concat with null string
Open Office 3.4.1 on Windows XP
Re: Concat with null string
Use EITHER ONE of the two statements below:
Explanation: The SQL function COALESCE will return the second value ( in this case, a string with a lengh of zero ) when the first value is NULL ( UNDEFINED ). You can read about the COALESCE function at:
http://www.hsqldb.org/doc/1.8/guide/ch09.html
Sliderule
Thanks to add [Solved] in your 1st post Subject (edit button top right) if this issue has been resolved.
Code: Select all
CONCAT( "OADDRESS1", COALESCE("OADDRESS2",'') )
"OADDRESS1" || COALESCE("OADDRESS2",'')
http://www.hsqldb.org/doc/1.8/guide/ch09.html
I hope this helps, please be sure to let me / us know.http://www.hsqldb.org/doc/1.8/guide/ch09.html wrote:
COALESCE(expr1,expr2,expr3,...)
if expr1 is not null then it is returned else, expr2 is evaluated and if not null it is returned and so on
Sliderule
Thanks to add [Solved] in your 1st post Subject (edit button top right) if this issue has been resolved.
Re: Concat with null string
Any arithmetic or logical operation or concatenation with Null returns Null. The Coalesce function handles this by replacing Null with anything appropriate.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: Concat with null string
Thanks for the reply!
It should work but now it says:
The query can not be executed. It is too complex.
Any ideas?
It should work but now it says:
The query can not be executed. It is too complex.
Any ideas?
Open Office 3.4.1 on Windows XP
Re: Concat with null string
Try setting the option Edit -> Run SQL Command Directly.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Re: Concat with null string
You did not mention the type of database indicated in the status bar. COALESCE runs fine with HSQLDB.rforester wrote:Thanks for the reply!
It should work but now it says:
The query can not be executed. It is too complex.
Any ideas?
The minimal set of functions for file based databases (dBase, spreadsheets, text etc) does not include COALESCE.
http://www.openoffice.org/dba/specifica ... tions.html
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice