Unable to get desired output in mysql <p>I am working on a project report which requires some tricky output from a single table.</p> <p>This is the structure of the table named: <strong>daily_visit_expenses</strong> <img src="https://i.stack.imgur.com/D1I0f.png" alt="daily_visit_expenses"></p> <p>having data like this:: <img src="https://i.stack.imgur.com/H4hlN.png" alt="enter image description here"></p> <p>now what i want the output is the combination of these three queries in a single column (any name), the queries are:</p> <pre><code>SELECT DISTINCT(`cust_1`) FROM `daily_visit_expenses` WHERE user='sanjay' AND `purpose_1`='Sales' SELECT DISTINCT(`cust_2`) FROM `daily_visit_expenses` WHERE user='sanjay' AND `purpose_2`='Sales' SELECT DISTINCT(`cust_3`) FROM `daily_visit_expenses` WHERE user='sanjay' AND `purpose_3`='Sales' </code></pre> <hr> <p>I want to get the output from a single query which is the combination of above three queries in a single column like <code>customers</code> which is <code>DISTINCT</code>.</p> <p>SQL Export:</p> <pre><code>CREATE TABLE IF NOT EXISTS `daily_visit_expenses` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `user` varchar(255) NOT NULL, `date` date NOT NULL, `status` varchar(50) NOT NULL, `location` varchar(50) NOT NULL, `cust_1` varchar(255) NOT NULL, `cust_2` varchar(255) NOT NULL, `cust_3` text NOT NULL, `cust_4` text NOT NULL, `purpose_1` varchar(20) NOT NULL, `purpose_2` varchar(20) NOT NULL, `purpose_3` varchar(20) NOT NULL, `purpose_4` varchar(20) NOT NULL, `visit_type` varchar(20) NOT NULL, `expenses` bigint(20) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=15 ; INSERT INTO `daily_visit_expenses` (`id`, `user`, `date`, `status`, `location`, `cust_1`, `cust_2`, `cust_3`, `cust_4`, `purpose_1`, `purpose_2`, `purpose_3`, `purpose_4`, `visit_type`, `expenses`) VALUES (5, 'sanjay', '2012-06-15', 'Working', 'Customer', 'S.G.R.S. Chemical &amp; Minral Industries', '', 'fatehpur foundry', '', 'Sales', '', 'Sales', '', 'Outstation', 2323), (8, 'sanjay', '2012-06-25', 'Working', 'Office', '', '', '', '', '', '', '', '', '', 0), (9, 'sanjay', '2012-06-09', 'Working', 'Office', '', '', '', '', '', '', '', '', '', 0), (10, 'sanjay', '2012-06-05', 'Working', 'Customer', 'V.N INTERNATIONAL', 'G.SURGIWEAR', '', '', 'Sales', 'Sales', '', '', 'Outstation', 332), (11, 'sanjay', '2012-06-30', 'Working', 'Customer', 'Ganesh Plywood-Sitapur', '', '', '', 'Service', '', '', '', 'Outstation', 434), (12, 'sanjay', '2012-06-04', 'Absent', '', '', '', '', '', '', '', '', '', '', 0), (13, 'sanjay', '2012-06-06', 'Absent', '', '', '', '', '', '', '', '', '', '', 0), (14, 'sanjay', '2012-06-08', 'Leave', '', '', '', '', '', '', '', '', '', '', 0); </code></pre>