Problems with CONCAT funcion using TQuery

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
flystar
Posts: 6
Joined: Fri 16 Apr 2010 14:45

Problems with CONCAT funcion using TQuery

Post by flystar » Fri 21 May 2010 20:33

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???? :?: :?: :?: :?: :( :( :(

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Tue 25 May 2010 11:58

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.

eduardosic
Posts: 387
Joined: Fri 18 Nov 2005 00:26
Location: Brazil

Re: Problems with CONCAT funcion using TQuery

Post by eduardosic » Wed 26 May 2010 03:14

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

Stefan Sordon
Posts: 1
Joined: Mon 28 Jun 2010 15:51

Post by Stefan Sordon » Mon 28 Jun 2010 15:57

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

Post Reply