0

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

dfg ert
  • 39
  • 6

2 Answers2

1

(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: Joins

DDS
  • 2,340
  • 16
  • 34
0

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
ali_codex
  • 113
  • 1
  • 13