Matching string with LIKE derived from sub-query Here is my query Where I want to match a string with a subquery output. But it is returning wrong result. What I am doing wrong? The concat part is not working as I try to run 

Concat('"', (SELECT sec_dep 
                                  FROM   admin_users 
                                  WHERE  uid = 11), '"')


this part only. it shows error.

SELECT * 
FROM   issues
WHERE  ( assigned_to_dept LIKE Concat('"', (SELECT sec_dep 
                              FROM   admin_users 
                              WHERE  uid = 11), '"') 
              OR assigned_to_dept LIKE Concat('"%,', (SELECT sec_dep 
                                FROM   admin_users 
                                WHERE  uid = 11), '"') 
              OR assigned_to_dept LIKE Concat('"', (SELECT sec_dep 
                              FROM   admin_users 
                              WHERE  uid = 11), ',%"') 
              OR assigned_to_dept LIKE Concat('"%,', (SELECT sec_dep 
                                FROM   admin_users 
                                WHERE  uid = 11), ',%"') ) 


thanx in advance.

UPDATE

admin_users Table

CREATE TABLE `admin_users` (
 `uid` int(11) NOT NULL AUTO_INCREMENT,
 `pri_dep` int(11) NOT NULL,
 `sec_dep` text NOT NULL,
 PRIMARY KEY (`uid`),
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8


issue table

CREATE TABLE `issues` (
 `id` int(10) NOT NULL AUTO_INCREMENT,
 `title` varchar(250) NOT NULL,
 `description` text,
 `assigned_by` int(11) NOT NULL,
 `assigned_to_users` text,
 `assigned_to_dept` int(11) DEFAULT NULL,
 PRIMARY KEY (`id`),
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8
I can only assume that you are getting no results returned? Always include your error text with questions here.

I input your table structures (+1 for providing the DDL BTW!):

issues:

mysql&gt; DESC issues;
+-------------------+--------------+------+-----+---------+----------------+
| Field             | Type         | Null | Key | Default | Extra          |
+-------------------+--------------+------+-----+---------+----------------+
| id                | int(10)      | NO   | PRI | NULL    | auto_increment |
| title             | varchar(250) | NO   |     | NULL    |                |
| description       | text         | YES  |     | NULL    |                |
| assigned_by       | int(11)      | NO   |     | NULL    |                |
| assigned_to_users | text         | YES  |     | NULL    |                |
| assigned_to_dept  | int(11)      | YES  |     | NULL    |                |
+-------------------+--------------+------+-----+---------+----------------+


admin_users:

mysql&gt; DESC admin_users;
+---------+---------+------+-----+---------+----------------+
| Field   | Type    | Null | Key | Default | Extra          |
+---------+---------+------+-----+---------+----------------+
| uid     | int(11) | NO   | PRI | NULL    | auto_increment |
| pri_dep | int(11) | NO   |     | NULL    |                |
| sec_dep | text    | NO   |     | NULL    |                |
+---------+---------+------+-----+---------+----------------+


I inputted some data:

INSERT INTO `issues` VALUES (1,'title1','desc1',1,'users1',3),
(2,'title10','desc10',1,'users10',10),(3,'title11','desc11',1,
'users10',11),(4,'title12','desc12',1,'users10',12),
(5,'title13','desc13',1,'users10',13);


and

INSERT INTO `admin_users` VALUES (1,9,'adsafsd'),(2,10,'zxvzvx'),
(3,11,'cgffdf'),(4,12,'iopouu'),(5,11,'adsafsd'),(9,15,'xver'),
(11,11,'waerwaer'),(12,15,'wcvvver');


I ran your query and it returns the empty set.

To check, I then ran the subquery that recurs:

SELECT sec_dep 
FROM   admin_users 
WHERE  uid = 11;


and the result was:

+----------+
| sec_dep  |
+----------+
| waerwaer |
+----------+


But, from DESC issues above, you have assigned_to_dept is an INT, so they can never match. You need to rethink your schema and/or query.