JOIN table in SQL PHP not working perfectly
23:03 14 Mar 2021

I am trying to select the multiple tables without join and any relationship. everything is working perfectly but I got an issue that the resulting output is repeating duplicate.

I am trying to represent by diagrams.

table_in

|------|------------------|--------------|-------|
|  ID  | component_in_key |  insert_date |  type |
|------|------------------|--------------|-------|
|  1   | 123456789        |  2021-02-01  |  I    |
--------------------------------------------------

table_request

|------|-------------------|--------------|-------|
|  ID  | component_req_key |  insert_date |  type |
|------|-------------------|--------------|-------|
|  1   | 123456789         |  2021-02-02  |   R   |
|  2   | 123456789         |  2021-02-03  |   R   |
|  3   | 123456789         |  2021-02-04  |   R   |
---------------------------------------------------

table_approve

|------|-------------------|--------------|-------|
|  ID  | component_apv_key |  insert_date |  type |
|------|-------------------|--------------|-------|
|  1   | 123456789         |  2021-02-05  |   A   |
|  2   | 123456789         |  2021-02-07  |   A   |
|  3   | 123456789         |  2021-02-08  |   A   |
---------------------------------------------------

SQL attemp is

SELECT *
FROM table_in, table_request, table_approve
WHERE table_in.component_in_key = 123456789 AS component
    AND table_request.component_req_key = 123456789
    AND table_approve.component_apv_key= 123456789
ORDER BY table_in.insert_date
    AND table_request.insert_date
    AND table_approve.insert_date

OUTPUT table_in.component_in_key is repeating 3 times.

LOOKING OUTPUT

|------+---------------+--------------+-------+
|  ID  | component |  insert_date |  type |
-----------------------------------------------
|  1   | 123456789     |  2021-02-01  |  I    |
|  2   | 123456789     |  2021-02-02  |  R    |
|  3   | 123456789     |  2021-02-03  |  R    |
|  4   | 123456789     |  2021-02-04  |  R    |
|  5   | 123456789     |  2021-02-05  |  A    |
|  6   | 123456789     |  2021-02-07  |  A    |
|  7   | 123456789     |  2021-02-08  |  A    |
 ---------------------------------------------

Please help me how I make it like this is PHP SQL.

mysql sql join left-join