get new records from table based on other one record in table

36 views Asked by At
SELECT group_no,group_name, dept_no, dept_name, brand, from_nnm,to_nnm 
  FROM xx_nnm_benchmark

I have one record from the above query for group_no 1100 and dept_no 50 I have one more deps table in which i have 8 more deptno from group_no 1100 I need to get 8more records with same group_no,name

1

There are 1 answers

8
mkpisk On

basically you need to join both these table on unique id. we can assume your 'group_no and group_name' together as unique and do inner join. left or right join might also work but i would go for inner for this task

SELECT a.group_no,
a.group_name,
a.dept_no as adepno,
a.dept_name as adepname,
b.dept_no,
b.dept_name,
a.brand,
a.from_nnm,
a.to_nnm
FROM xx_nnm_benchmark a inner join deps b
on (a.group_no = b.group_no and a.group_name = b.group_name)