I have the following mysql table. I have been trying to select all the rows which are related with the row that has B
as value in the code
column. The relation is based on the value of the column trans_id
id trans_id code amount side
1 1 A 200 left
2 1 B 200 right
3 2 J 100 right
4 2 C 100 right
5 2 B 200 left
6 3 A 630 right
7 3 K 630 left
My Expected Result:
id trans_id code amount side
1 1 A 200 left
3 2 J 100 right
4 2 C 100 right
Could you please tell me what should be the mysql query to achieve this?
Thanks :)