Jarwin Gines Jarwin Gines - 3 months ago 7
MySQL Question

mysql join 1 table w/ 1 row and table w/ many rows

1st table 2nd table

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


Output

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

Answer

Try the following query:

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