I have been using this site for years now and this is the first time I'm asking a question here, so kinda scared right now :D
Here's what my problem is, I have got two tables. In table_a I got three columns and in table_b I got 5. So the setup right now looks something like this:
table_a
| r_id | foo | bar |
+------+-------+-----+
| 1 | dude | 5 |
+------+-------+-----+
| 2 | homie | 6 |
+------+-------+-----+
| 3 | bro | 7 |
+------+-------+-----+
table_b
| id | ada | rea | lm | cor |
+----+-------+-----+------+------+
| 5 | ching | ink | jk | 32.4 |
+----+-------+-----+------+------+
| 1 | momo | pal | lmao | 95.5 |
+----+-------+-----+------+------+
| 6 | mama | pen | lol | 26.9 |
+----+-------+-----+------+------+
| 4 | chac | pin | fun | 91.2 |
+----+-------+-----+------+------+
| 7 | chim | lap | funk | 82.4 |
+----+-------+-----+------+------+
| 9 | cho | kil | fin | 38.1 |
+----+-------+-----+------+------+
Now what I'm trying to do is to get all the data from table_a and then only get lm
from table_b. I'm getting all the data from table_a like this:
SELECT r_id, foo, bar from table_a
I need to use the ids I get from bar
column to get lm
from table_b. So is there a way I can pass an array to only get the data based on the ids in an array? If not, then what would be the most efficient way to get those?
The output I'm expecting is jk, lol, funk
.
Would appreciate any help, thanks!