how to join both query in mysql

Posted by Gow.Net under Others on 3/22/2013 | Points: 10 | Views : 927 | Status : [Member] | Replies : 3
hi in my application i am using MySQL i need how to join both query
output column name question_id,nid,alert

-- get notification from answer                     

SELECT A.question_id,NT.id AS nid, COUNT(NT.user_id) AS alert FROM notification_tos AS NT ,
notifications AS N,
answers AS A
WHERE
N.item_id=A.id AND
N.item_type='Answer' AND
NT.notification_id=N.id AND
NT.is_read=0 AND
NT.user_id=3 AND
NT.requirement_id=1 GROUP BY A.question_id

-- get notification from question

SELECT N.item_id AS question_id , NT.id AS nid ,COUNT(NT.user_id) AS alert FROM notifications AS N,
notification_tos AS NT ,
questions AS Q WHERE
NT.is_read=0 AND
N.id=NT.notification_id AND
N.item_type='Question' AND
Q.id=item_id AND
NT.user_id=3 AND
NT.requirement_id=1 GROUP BY N.item_id


gowthaman8870226416


Responses

Posted by: Karthikreddy on: 3/22/2013 [Member] Starter | Points: 25

Up
0
Down
you can use inner join concept

example query

SELECT     Employee_Info.Employee_Name, Designation.Designation

FROM Designation INNER JOIN
Employee_Info ON Designation.Employee_ID = Employee_Info.Employee_ID AND Designation.Designation_ID = Employee_Info.Designation_ID


k@rth!k
karthikreddy08a50@gmail.com

Gow.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jayakumars on: 3/22/2013 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi
post your Dbscript also


what is ur expect output

Mark as Answer if its helpful to you

Gow.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikreddy on: 3/22/2013 [Member] Starter | Points: 25

Up
0
Down

SELECT [Employee_ID]

,[Employee_Name]
,[Designation_ID]
,[Employee_Code]
,[Joining_Date]
,[Personal_ID]
,[Official_ID]
,[Working_Hours_ID]
,[Role_ID]
,[Dept_ID]
FROM [emppayroll].[dbo].[Employee_Info]

---------------------------------------------------------
SELECT [Designation_ID]
,[Designation]
,[Employee_ID]
FROM [emppayroll].[dbo].[Designation]


i was selected only empname and desination

k@rth!k
karthikreddy08a50@gmail.com

Gow.Net, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response