sql - Fetch data from table based on common value present in joining table -
i have 2 tables table1 , table2 , joining table table_1_2 holds primary key of both table1 , table2 tables. table diagram
i want fetch records table2 based on values of table1.suppose if user selects t1 , t2 record table1 p1 should fetched table2 p1 has got record both t1 , t2 seen in joining table. if user selects t1 record table1 both p1 , p2 value should fetched table2 t1 has associated record both p1 , p2.
what query can used fetch record condition?it helpful if can provide rails query same.
Comments
Post a Comment