0
SELECT id
     , name
     , bonus 
  FROM table1 a
  LEFT 
  JOIN table2 b
    ON a.id = b.employee_id
intersect
SELECT id
     , name
     , bonus 
  FROM table1 a
 RIGHT 
  JOIN table2 b
    ON a.id = b.employee_id;
Strawberry
  • 33,750
  • 13
  • 40
  • 57
  • INTERSECT not exists in MySQL. Use WHERE EXISTS or INNER JOIN instead. – Akina Mar 19 '21 at 05:37
  • Check out this one https://www.mysqltutorial.org/mysql-intersect/ and this one https://stackoverflow.com/questions/2302873/sql-syntax-error-with-intersect – Onur Baştürk Mar 19 '21 at 05:38
  • And if you're still struggling, see https://meta.stackoverflow.com/questions/333952/why-should-i-provide-a-minimal-reproducible-example-for-a-very-simple-sql-query – Strawberry Mar 19 '21 at 05:49
  • Mysql does not yet support intersect, though mariadb does – ysth Mar 19 '21 at 06:41

1 Answers1

0
SELECT tab1.id,tab1.name,tab1.bonus (SELECT id
     , name
     , bonus 
  FROM table1 a
  LEFT 
  JOIN table2 b
    ON a.id = b.employee_id) as tab1
INNER JOIN 
(SELECT id
     , name
     , bonus 
  FROM table1 a
 RIGHT 
  JOIN table2 b
    ON a.id = b.employee_id) as tab2 ON tab1.id=tab2.id;

You can try like this

ankit singh
  • 565
  • 3
  • 8