CREATE TABLE `fruits` (
      `fruit_id` int(11) default NULL,
      `fruit_name` varchar(255) collate latin1_general_ci default NULL
    );

INSERT INTO fruits(fruit_id, fruit_name) 
          VALUES (101, 'Mango'),
                 (102, 'Apple'),
                 (103, 'Orange'),
                 (104, 'Pineapple'),
                 (105, 'Lemon'),
                 (106, 'Custard');
SELECT row
  FROM (SELECT fruit_id, CAST(fruit_id AS CHAR(255)) row
          FROM fruits
        UNION
        SELECT fruit_id, CAST(fruit_name AS CHAR(255)) row
          FROM fruits) s
 WHERE fruit_id = 101;

Output

 101
 Mango 

Leave a reply