[MYSQL] my query is:-

SELECT * FROM (SELECT 'attendence' AS 'type',userAS 'username', STR_TO_DATE(in_time, '%d-%m-%Y %H:%i:%s') AS 'time_in', 'in_address' AS 'address_in', STR_TO_DATE(out_time, '%d-%m-%Y %H:%i:%s') AS 'time_out', 'out_address' AS 'address_out' FROM attendence UNION ALL SELECT 'visit', username, STR_TO_DATE(visit_time_in, '%d-%m-%Y %H:%i:%s'), location_in, STR_TO_DATE(visit_time_out, '%d-%m-%Y %H:%i:%s'), location_out FROM visits) t WHERE t.username = 'MCCuser0036' AND time_in BETWEEN STR_TO_DATE('01-01-2019', '%d-%m-%Y %H:%i:%s') AND STR_TO_DATE('27-04-2019', '%d-%m-%Y %H:%i:%s') ORDER BY time_in ASC;

and result is:-

+------------+-------------+---------------------+----------------------------------------------------------------------------------------------------------------------+---------------------+-----------------------------------------------------------------------------------------------------+
| type       | username    | time_in             | address_in                                                                                                           | time_out            | address_out                                                                                         |
+------------+-------------+---------------------+----------------------------------------------------------------------------------------------------------------------+---------------------+-----------------------------------------------------------------------------------------------------+
| attendence | MCCuser0036 | 2019-01-25 11:02:09 | in_address                                                                                                           | 2019-01-25 11:02:10 | out_address                                                                                         |
| visit      | MCCuser0036 | 2019-02-13 11:46:55 | Sewri - Chembur Rd, Trombay Indusrial Area, Antop Hill, Mumbai, Maharashtra 400037, India                            | 2019-02-13 11:47:00 | Sewri - Chembur Rd, Trombay Indusrial Area, Antop Hill, Mumbai, Maharashtra 400037, India           |
| visit      | MCCuser0036 | 2019-02-14 11:47:04 | Sewri - Chembur Rd, Trombay Indusrial Area, Antop Hill, Mumbai, Maharashtra 400037, India                            | 2019-02-14 11:47:10 | Sewri - Chembur Rd, Trombay Indusrial Area, Antop Hill, Mumbai, Maharashtra 400037, India           |
| visit      | MCCuser0036 | 2019-02-14 11:51:07 | Kokri Agar Road, Koliwada, Kokri Agar, Sion, Mumbai, Maharashtra 400037, India                                       | 2019-02-14 11:51:10 | Kokri Agar Road, Koliwada, Kokri Agar, Sion, Mumbai, Maharashtra 400037, India                      |
| visit      | MCCuser0036 | 2019-02-14 11:51:30 | Kokri Agar Road, Koliwada, Kokri Agar, Sion, Mumbai, Maharashtra 400037, India                                       | 2019-02-14 11:51:34 | Kokri Agar Road, Koliwada, Kokri Agar, Sion, Mumbai, Maharashtra 400037, India                      |
| visit      | MCCuser0036 | 2019-02-14 11:51:36 | Kokri Agar Road, Koliwada, Kokri Agar, Sion, Mumbai, Maharashtra 400037, India                                       | 2019-02-14 11:51:39 | Kokri Agar Road, Koliwada, Kokri Agar, Sion, Mumbai, Maharashtra 400037, India                      |
| visit      | MCCuser0036 | 2019-02-18 15:09:42 | Kokri Agar Road, Koliwada, Kokri Agar, Sion, Mumbai, Maharashtra 400037, India                                       | NULL                |                                                                                                     |
| visit      | MCCuser0036 | 2019-02-20 12:11:30 | Sewri - Chembur Rd, Trombay Indusrial Area, Antop Hill, Mumbai, Maharashtra 400037, India                            | 2019-02-20 13:44:36 | Building No 57, Gaurav Harmony, CGS Colony, Sector 7, Antop Hill, Mumbai, Maharashtra 400037, India |
| attendence | MCCuser0036 | 2019-02-25 10:59:08 | in_address                                                                                                           | 2019-02-25 10:59:16 | out_address                                                                                         |
| visit      | MCCuser0036 | 2019-02-25 13:05:42 | Kokri Agar Road, Koliwada, Kokri Agar, Sion, Mumbai, Maharashtra 400037, India                                       | NULL                |                                                                                                     |
| visit      | MCCuser0036 | 2019-03-11 12:48:28 | jay maharashNagar kokri agar S.M road anophill church Near By sayyed alam, musjid, Mumbai, Maharashtra 400037, India | NULL                |                                                                                                     |
| attendence | MCCuser0036 | 2019-03-12 10:59:54 | in_address                                                                                                           | 2019-03-12 11:00:24 | out_address                                                                                         |
| attendence | MCCuser0036 | 2019-03-14 11:01:11 | in_address                                                                                                           | 2019-03-14 11:01:28 | out_address                                                                                         |
| attendence | MCCuser0036 | 2019-03-25 11:03:10 | in_address                                                                                                           | 2019-03-25 11:16:12 | out_address                                                                                         |
| attendence | MCCuser0036 | 2019-03-26 11:30:47 | in_address                                                                                                           | NULL                | out_address                                                                                         |
| attendence | MCCuser0036 | 2019-03-27 10:36:30 | in_address                                                                                                           | 2019-03-27 10:49:05 | out_address                                                                                         |
| attendence | MCCuser0036 | 2019-03-28 17:18:01 | in_address                                                                                                           | NULL                | out_address                                                                                         |
| attendence | MCCuser0036 | 2019-04-01 15:29:08 | in_address                                                                                                           | NULL                | out_address                                                                                         |
| visit      | MCCuser0036 | 2019-04-01 15:55:45 | 736, Aala Hazrat Rd, Jagruti Nagar, Nehru Nagar, Kurla East, Mumbai, Maharashtra 400071, India                       | NULL                |                                                                                                     |
| attendence | MCCuser0036 | 2019-04-11 15:17:56 | in_address                                                                                                           | NULL                | out_address                                                                                         |
| attendence | MCCuser0036 | 2019-04-23 17:41:05 | in_address                                                                                                           | 2019-04-23 17:42:54 | out_address                                                                                         |
+------------+-------------+---------------------+----------------------------------------------------------------------------------------------------------------------+---------------------+-----------------------------------------------------------------------------------------------------+
21 rows in set, 17 warnings (0.15 sec)

i dont know no why i am getting 'in_address' in 'address_in' column and 'out_address' in 'addess_out' column

what i want in my result is value insted of 'in_address','out_address'

Use backticks instead of apostrophes

`attendence` AS 'type'
,`in_address` AS 'address_in'
,`out_address` AS 'address_out'
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.