Reputation: 39
i want result of two table when i do a select,
first table A :
+------+---------------------+--------------------+-----------------+
| CID | time | step | time_in_seconde |
+------+---------------------+--------------------+-----------------+
| 3 | 2017-07-27 06:35:52 | gege | 13.229 |
| 4 | 2017-07-27 06:36:56 | titi | 12.823 |
| 5 | 2017-07-27 06:55:04 | fefe | 12.667 |
second table B :
+------+---------------------+-----------------+
| CID | time | cpu |
+------+---------------------+-----------------+
| 3 | 2017-07-27 06:35:52 | 0.01 |
| 4 | 2017-07-27 06:36:56 | 0.05 |
| 5 | 2017-07-27 06:55:04 | 0.03 |
i want this result:
+------+---------------------+--------------------+-----------------+-----------------+
| CID | time | step | time_in_seconde | cpu |
+------+---------------------+--------------------+-----------------+-----------------+
| 3 | 2017-07-27 06:35:52 | gege | 13.229 | 0.01 |
| 4 | 2017-07-27 06:36:56 | titi | 12.823 | 0.05 |
| 5 | 2017-07-27 06:55:04 | fefe | 12.667 | 0.03 |
thanks for any response
Upvotes: 0
Views: 47
Reputation: 113
Use inner
join like below
select a.cid,a.time,a.step,a.time_in_second,b.cpu
from t1 a
inner join t2 b
on a.cid=b.cid
Upvotes: 0
Reputation: 2479
(INNER) JOIN is what you need
select a.CID, a.time, step , time_in_seconde,cpu
from tab a join tab b
on a.cid=b.cid
Just to add some 'visual' explanations of joins:
Upvotes: 1