Click here to Skip to main content
15,747,766 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:

i need some help.
i have two tables(userticket and adminticketreply).
if user generate one ticket and admin put some reply on same ticket.
then how can i get number of rows from both the table on same ticketnumber.
both table contain ticketnumber column.

ticketnumber                        message
   20                                hello
   21                                miss u
   22                                hye

means user generate a ticket with number 20 and send to admin and then admin see the ticket and
got the ticket number 20 automatically.and then he send reply to user.

ticketnumber                         reply     
20                                    welcome
20                                    i m urs
20                                    wanna meet
21                                    see yaa
22                                    byeeee
22                                    happy
20                                    time is coming

then in both the table,the ticketnumber is 20.
i would like to add both the number rows in both the table on same ticketnumber.
Means the answer would come 5 after count the number of rows from both table on same ticket number 20.
so i want to know how to count both the rows from both the table.

i tried count with but not get exact number through it.
Updated 22-Apr-11 22:18pm
Bruno Tagliapietra 23-Apr-11 3:50am    
Try asking your computer "Can I have that damned number??? ... please."

I mean, be more clear posting your questions please.. otherwise you'll get no answers just because it's impossible to give one
thatraja 23-Apr-11 4:08am    
Not clear....explain a little bit more

1 solution

Not sure what you mean, but I think something like the following should do the trick...

declare @ticketnumber as (big)int -- Whatever type you use.
set @ticketnumber = 20 -- This probably is passed as a parameter to an SP.
declare @count1 as int
declare @count2 as int

@count1 = COUNT(*)
from userticket
where ticketnumber = @ticketnumber

@count2 = COUNT(*)
from adminticketreply
where ticketnumber = @ticketnumber

select 'count' = @count1 + @count2

I don't know if it is a 'clean' solution, but it works for me.
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