mysql连接1个表w / 1行和表w /多行

时间:2016-09-03 00:35:57

标签: mysql database

1st table           2nd table

---------------      ----------
|id|name|hours|      |id|phour|
---------------      ----------
|1 |samp|  7  |      |1 |  10 |
---------------      ----------
|2 |smp2|  1  |

输出

------------------
|phour|name|hours|
------------------
|  10 |samp|  7  |
------------------
|     |smp2|  1  |

1 个答案:

答案 0 :(得分:0)

尝试以下查询:

select phour, name, hours from table1 right join table2 on table1.id=table2.id