Page 1 of 1

Problems with CONCAT funcion using TQuery

Posted: Fri 21 May 2010 20:33
by flystar
Good morning

When i use the Tquery componente of MYDAC components,
and I use a QUERY like this:

"Select concat(Name,' ', FirstName,' ', SecondName) from NamesTable"

In a direct MySQL console or maybe another Mysql Software Admin i get a complete name of the persons in this table.

Buy if I use a Tquery component and some of the columns like Name or maybe FisrtName or may SecondName has a null or empty value, then the result of this record in the query is empty, and i dont understand the reazon.
Is a bug of the component???? :?: :?: :?: :?: :( :( :(

Posted: Tue 25 May 2010 11:58
by Dimon
Such result is returned by MySQL server and doesn't depend on MyDAC. Please make sure that you can get another result with a third-party MySQL client and with the same database.

Re: Problems with CONCAT funcion using TQuery

Posted: Wed 26 May 2010 03:14
by eduardosic
flystar wrote:Good morning

When i use the Tquery componente of MYDAC components,
and I use a QUERY like this:

"Select concat(Name,' ', FirstName,' ', SecondName) from NamesTable"

In a direct MySQL console or maybe another Mysql Software Admin i get a complete name of the persons in this table.

Buy if I use a Tquery component and some of the columns like Name or maybe FisrtName or may SecondName has a null or empty value, then the result of this record in the query is empty, and i dont understand the reazon.
Is a bug of the component???? :?: :?: :?: :?: :( :( :(
Concat work very well with mydac.. please.. post the program code..

try the SQL

Select
concat(Name,' ', FirstName,' ', SecondName) as MyField
from
NamesTable

Posted: Mon 28 Jun 2010 15:57
by Stefan Sordon
Use concat_ws to concat strings with NULL values.
This is an MYSQL thing, read this:
http://dev.mysql.com/doc/refman/5.0/en/ ... _concat-ws

Code: Select all

Select
concat_ws(' ', Name, FirstName, SecondName) as MyFullName
from
NamesTable