Click here to Skip to main content
15,893,381 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How can I write the Query without using Subquery.

SQL
Select * from 
(Select A.ContactID, B.CASLOptIN,B.CASLOptOut,B.CASLException From Contact A  inner Join GE_ContactInfo B on A.CONTACTID=B.CONTACTID Where A.Accountid ='XXXXXXXXXX') as Casl 
where(Casl.CASLOptOut ='F' or Casl.CASLEXCEPTION is null) or (Casl.CASLEXCEPTION ='F' or Casl.CASLEXCEPTION is null)


I dont want to use SubQuery in this case....What can be the Alternative Query for this.
Posted

1 solution

... something like this:

SQL
SELECT 
 A.ContactID, 
 B.CASLOptIN,
 B.CASLOptOut,
 B.CASLException 
FROM
 Contact A INNER JOIN GE_ContactInfo B 
  ON A.CONTACTID=B.CONTACTID 
WHERE 
 A.Accountid ='XXXXXXXXXX'
AND
(
 (B.CASLOptOut ='F' or B.CASLEXCEPTION is null) 
OR
 (B.CASLEXCEPTION ='F' or B.CASLEXCEPTION is null)
)


Hope it helps.
 
Share this answer
 
v2
Comments
lovejeet0707 8-Sep-14 10:28am    
Spot On.....!
Thanks :) :)
hypermellow 8-Sep-14 10:35am    
Glad it helped! Thanks.

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