Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7785211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:13:10+00:00 2026-06-01T20:13:10+00:00

I have two tables payroll_advance and payroll_advrtn ,and i supposed to do full outer

  • 0

I have two tables payroll_advance and payroll_advrtn,and i supposed to do full outer join to get my require result.But,I’m sure full outer join isn’t possible in mysql and also i know that full outer join is possible by using the union.But i don’t know how can i do join at the following query.

My payroll_advance table produce the following result.

SELECT _id,_tid,_dt,sum(_amount) as _advance FROM payroll_advance WHERE YEAR( _dt )=YEAR(CURDATE()) AND MONTH(_dt) = MONTH(CURDATE()) group by _tid;

+-----+-------+------------+---------+
| _id | _tid  | _dt        | _advance|
+-----+-------+------------+---------+
|  17 | hjg   | 2012-04-18 |    2151 |
|  22 | RKT01 | 2012-04-10 |    2098 |
|  14 | RKT04 | 2012-04-18 |    1511 |
|  16 | RKT09 | 2012-04-09 |     250 |
|  15 | RKT10 | 2012-04-17 |    1313 |
|   8 | RKT21 | 2012-04-03 |    1321 |
|  19 | RKT31 | 2012-04-26 |    2512 |
|  20 | RKT33 | 2012-04-10 |    2250 |
|  25 | T01   | 2012-04-11 |    2500 |
+-----+-------+------------+---------+

And payroll_advrtn gives the following result.

SELECT _id,_tid,_dt,sum(_amount) as _advrtn FROM payroll_advrtn WHERE YEAR( _dt ) = YEAR(CURDATE()) AND MONTH(_dt) = MONTH(CURDATE()) group by _tid;
+-----+-------+------------+---------+
| _id | _tid  | _dt        | _advrtn |
+-----+-------+------------+---------+
|   9 | RKT02 | 2012-04-10 |    2500 |
|   8 | RKT04 | 2012-04-20 |     150 |
+-----+-------+------------+---------+

But i want something like the following result by combining the above two result.

 +------+-------+-------+------------+----------+---------+
| _id  | _tid  | _tid  | _dt        | _advance | _advrtn |
+------+-------+-------+------------+----------+---------+
|   17 | hjg   | NULL  | 2012-04-18 |     2151 |    NULL |
|   22 | RKT01 | NULL  | 2012-04-10 |      999 |    NULL |
|   14 | RKT04 | RKT04 | 2012-04-18 |       11 |     150 |
|   16 | RKT09 | NULL  | 2012-04-09 |      250 |    NULL |
|   15 | RKT10 | NULL  | 2012-04-17 |     1313 |    NULL |
|    8 | RKT21 | NULL  | 2012-04-03 |     1321 |    NULL |
|   19 | RKT31 | NULL  | 2012-04-26 |     2512 |    NULL |
|   20 | RKT33 | NULL  | 2012-04-10 |     2250 |    NULL |
|   25 | T01   | NULL  | 2012-04-11 |     2500 |    NULL |
| NULL | NULL  | RKT02 | NULL       |     NULL |    2500 |
+------+-------+-------+------------+----------+---------+

Any help will be appreciated.Thanks!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T20:13:11+00:00Added an answer on June 1, 2026 at 8:13 pm

    In order to do the FULL OUTER JOIN you can do the LEFT OUTER JOIN and UNION with RIGHT OUTER JOIN (provided that MySql still does not support FULL OUTER JOIN):

    select * from A as a
        left outer join B as b on a.col = b.col
    union
    select * from A as a
        right outer join B as b on a.col = b.col
    

    Note that you can use subqueries for A and B – which should work with your queries. In your case:

    select * from (SELECT * FROM t1) as a
        left outer join (SELECT * FROM t2) as b on a._tid = b._tid
    union
    select * from (SELECT * FROM t1) as a
        right outer join (SELECT * FROM t2) as b on a._tid = b._tid
    

    With result being equal to (provided that I didn’t my a mistake in copy-pasting your data):

    +------+-------+------------+----------+------+-------+------------+----------+
    | _id  | _tid  | _dt        | _advance | _id  | _tid  | _dt        | _advartn |
    +------+-------+------------+----------+------+-------+------------+----------+
    |   17 | hjg   | 2012-04-18 |     2151 | NULL | NULL  | NULL       |     NULL |
    |   22 | RKT01 | 2012-04-10 |     2098 | NULL | NULL  | NULL       |     NULL |
    |   14 | RKT04 | 2012-04-18 |     1511 |    8 | RKT04 | 2012-04-20 |      150 |
    |   16 | RKT09 | 2012-04-09 |      250 | NULL | NULL  | NULL       |     NULL |
    |   15 | RKT10 | 2012-04-17 |     1313 | NULL | NULL  | NULL       |     NULL |
    |    8 | RKT21 | 2012-04-03 |     1321 | NULL | NULL  | NULL       |     NULL |
    |   19 | RKT31 | 2012-04-26 |     2512 | NULL | NULL  | NULL       |     NULL |
    |   20 | RKT33 | 2012-04-10 |     2250 | NULL | NULL  | NULL       |     NULL |
    |   25 | T01   | 2012-04-11 |     2500 | NULL | NULL  | NULL       |     NULL |
    | NULL | NULL  | NULL       |     NULL |    9 | RKT02 | 2012-04-10 |     2500 |
    +------+-------+------------+----------+------+-------+------------+----------+
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables Master Detail In the Master & Detail table I get
I have two tables, and I want to get the last enterd date. The
i have two tables products and reviews each product has several reviews linked by
I have two tables : teachers (teacher_id,teacher_name) courses (teacher_id,course_id) And I need to display
I have two tables on a webform. On a button click I want to
i have two tables both are related with primary-foreign key ralation and i have
I have two tables, the first has a primary key that is an identity,
I have two tables: Videos -------------- VideoID VideoGroupID CreatorUserID and VideoTags -------------- VideoID TagID
I have two tables, one for routes and one for airports. Routes contains just
I have two tables, for example: Table A Table B ======= ======= Name |

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.