How can I join two tables with different number of rows in MySQL?

前端 未结 3 1545
野性不改
野性不改 2021-01-13 11:00

I have two tables which I want to connect.

TABLE_A:

+-----------+-----------+---------+
| row_id    | category  | val_1   |
+-----------+----------         


        
3条回答
  •  囚心锁ツ
    2021-01-13 11:44

    Try an outer join.

    SELECT TABLE_A.row_id, TABLE_A.category, TABLE_A.val_1, TABLE_B.val_2
    FROM TABLE_B
    LEFT OUTER JOIN TABLE_A ON TABLE_B.row_id = TABLE_A.row_id
    ORDER BY row_id;
    

提交回复
热议问题