Concat

Hi

I’m usinng GROUP_CONCAT to concatinate query results,

 
eg : SELECT  CAST(GROUP_CONCAT(`timestamp` SEPARATOR "','")AS BINARY) as `timestamp`

and it results


2010-03-05 04:38:01[B]','[/B]2010-03-05 04:38:05[B]','[/B]2009-12-24 04:15:49

i like to run above query like this

Select * from demo where demo IN(SELECT  CAST(GROUP_CONCAT(`timestamp` SEPARATOR "','"))

if you see the results single quotes is missing from first and last position.

so how can we concatinate single quotes at both ends

Thanks in advance


 SELECT  CONCAT([B]"'",[/B]CAST(GROUP_CONCAT(`timestamp` SEPARATOR "','")AS BINARY)[B],"'"[/B]) as `timestamp`

it works now

I have certain doubt my subquery is not working in “IN”

It does not returns any results.

how can i give subquery properly inside “IN”

SELECT * 
  FROM demo 
 WHERE demo IN ( SELECT `timestamp`
                   FROM sometable )

That was mistake from my side , we dont have to GROUP_CONCAT when using subquery inside “IN”

thanks for the help :wink: