Click here to Skip to main content
15,881,380 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have two tables(sql)
one table :number,name,place,department.
second table:number,address,phone-no.
i need receive data if the any of the department members contain greater than one member.
Posted
Updated 25-Jan-13 3:21am
v2
Comments
CHill60 25-Jan-13 9:10am    
Your question is not at all clear and I'm not sure what the relevence of your second table is. I think you're saying give me the department if it contains more than one name? Something along the lines of select department from table1 group by department having count(*) > 1
[no name] 25-Jan-13 9:27am    
I can suggest for the foreign key concepts implimented there in the both tables so that you can get the related data from there by joining the tables.

1 solution

If I understand your question right, you want to select the persons that are assigned to two or more departments?
Sounds a bit like homework, but anyway, try this:

SQL
select name, count(department) from  persl group by (name) having count(department) > 1



hope this helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900