Click here to Skip to main content
15,885,895 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I have two table
name: first and second
Table: first
ID name
1 aaa
2 bbb
Table: second
ID name
1 aaa
2 ccc
3 ddd
4 eee

Now i want to combine like

fname sname
2 4

The output show the no of row in corresponding tables.
Any suggestions pls................!
Posted
Comments
Sampath Lokuge 5-Dec-13 2:02am    
Question is not clear.So Can we have more information about your table structure and your requirement (from where fname/sname columns came)?
prabhatsp 5-Dec-13 2:05am    
fname from first table ,sname from second table,
2 - number of row in first table
4 - number of row in second table

SQL
SELECT (SELECT COUNT(ID) FROM first) AS fname,
       (SELECT COUNT(ID) FROM second) AS sname
 
Share this answer
 
Comments
prabhatsp 5-Dec-13 4:15am    
very very thanks..............! i got the answer
Most Welcome. My Pleasure. :)
Sampath Lokuge 8-Dec-13 9:53am    
+ 5 :)
Thanks a lot Sampath. :)
Do some learning about TSQL, it will be of great use.

You have not defined the join criteria so I'll assume the ID

SQL
Select first.name as FName, second.name as LName
From first f
inner join second s on s.ID = F.ID 
 
Share this answer
 
hii prabhatsp

Try this ,i tried run successfully...reply

SELECT 
(SELECT COUNT(*) FROM FIRST) AS fname,
(SELECT COUNT(*) FROM SECOND) AS sname;
 
Share this answer
 
Comments
prabhatsp 5-Dec-13 4:16am    
very very thanks..............! i got the answer
[no name] 5-Dec-13 4:33am    
most welcome.....

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