with the left join all the rows in the left table will be in the output and only the rows in the right table that match will be joined in the output
if you just want the rows that match use an inner join
If this posts assists in resolving the question, please mark it helpful or as the 'correct answer' if it resolves the question. This will help other users find the same answer/resolution. Thank you.
i want all the rows in the left table with the rows in the right table that match, it´s for that, that i think the result would be 5136 rows instead 5188 rows.
You are likely getting some duplication of rows. In your example above you get 50+ extra rows and I suspect it's because rows on the left are finding multiple matches on the right.
To illustrate, consider these two tables:
ID Value A 1 B 2 C 3
ID Color A Red B Blue B Black C Green
If you left joined on ID and Table 1 was your left table, then you'd get the following Rows:
ID Value Color A 1 Red B 2 Blue B 2 Black C 3 Green
So you'd end up with 4 rows even though your left table only had 3.
You'll need to make sure that the right table doesn't contain duplicate key values for the match (Fecha and Hora) in your example. You can potentially use an aggregation prior to the join to fix that, but it might depend a bit on your original data.
On a related note, notice that NULL values never match, so if you did want to retain them from the left side, you'll need to change them to another value first.
Hope that helps!