Click here to Skip to main content
15,906,645 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to merge two query data into one ,and the second query should be merge in parallel

SQL
SELECT  ccew.cce_weightages_Id,ccew.Weightages,Criteria_Type,ccecat.ExamCat_Name  from tbl_CceWeightage ccew inner join tbl_CceExamCategory  ccecat on ccecat.CceExamCat_Id=ccew.CceExamCat_Id

select cwc.Course_Id  from tbl_CceWeightagesCourse cwc  where cwc.cce_weightages_Id in(select we.cce_weightages_Id from tbl_CceWeightage we)


Course_Id column output merge with first query output.
plz help me .
Posted
Updated 8-Jan-14 21:19pm
v4
Comments
Aarti Meswania 9-Jan-14 3:43am    
provide sample table data and required o/p
manvendra patel 9-Jan-14 3:56am    
actually i am using two table

table 1-


CREATE TABLE [dbo].[tbl_CceWeightage](
[cce_weightages_Id] [int] IDENTITY(1,1) NOT NULL,
[Weightages] [int] NULL,
[CceExamCat_Id] [int] NULL,
[Criteria_Type] [nvarchar](50) NULL,
[Created_At] [datetime] NULL,
[Updated_At] [datetime] NULL,
CONSTRAINT [PK_tbl_CceWeightage] PRIMARY KEY CLUSTERED
(
[cce_weightages_Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

output from first query is-
1 123 FA dsfgdsf
2 32 SA frwewrw
3 20 FA frwewrwwqer
4 12 FA minterm exam
5 13 FA minterm exam
6 20 SA minterm exam
7 25 SA minterm exam

and second table is -


CREATE TABLE [dbo].[tbl_CceWeightagesCourse](
[WeightagesCourse_Id] [int] IDENTITY(1,1) NOT NULL,
[cce_weightages_Id] [nvarchar](50) NULL,
[Course_Id] [nvarchar](50) NULL,
[Created_At] [datetime] NULL,
[Updated_At] [datetime] NULL,
CONSTRAINT [PK_tbl_CceWeightagesCourse] PRIMARY KEY CLUSTERED
(
[WeightagesCourse_Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

and output of second query is

3
3
3
3
2
2
2

i want to merge second query output with first query output as a column not row.

If you want to join data, please see this:
SQL
SELECT  ccew.cce_weightages_Id,ccew.Weightages,Criteria_Type,ccecat.ExamCat_Name, cwc.Course_Id
FROM tbl_CceWeightage ccew
    INNER JOIN tbl_CceExamCategory  ccecat ON ccecat.CceExamCat_Id=ccew.CceExamCat_Id
    INNER JOIN tbl_CceWeightage cwc ON cwc.cce_weightages_Id = ccew.cce_weightages_Id 


[EDIT]
SQL
SELECT  ccew.cce_weightages_Id,ccew.Weightages,Criteria_Type,ccecat.ExamCat_Name
FROM tbl_CceWeightage ccew
    INNER JOIN tbl_CceExamCategory  ccecat ON ccecat.CceExamCat_Id=ccew.CceExamCat_Id
WHERE ccew.cce_weightages_Id NOT IN (SELECT cce_weightages_Id FROM tbl_CceWeightage)

[/EDIT]
 
Share this answer
 
v2
Comments
manvendra patel 9-Jan-14 4:21am    
main problem is that i want get all data from table one with Course _Id ,but your query returning
on the basis of cce_weightages_Id is match

but i want to get all value from table one data which cce_weightages_Id is not exists.in table 2.
Maciej Los 9-Jan-14 5:36am    
See updated answer.
I suggest reading my first SQL article here[^], which explains what joins are.
 
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