Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
aswindba1
Yak Posting Veteran
62 Posts |
Posted - 2013-12-23 : 00:12:21
|
Table 1 : custemaildim emailADDr |||||| SendSurveysome@gmail.com|||||| Nexam@gmail.com|||||| ytest@gmail.com|||||| YTable 2: UnsubscribeemailADDr |||||| Snoexam@gmail.com |||||| 2new1@gmail.com |||||| 2 Requirement :1. Initially passing the email address to custemaildim table to find out the Send Survey Flag.So here we will get send survey flag would be Yes or No from the above table.2. So we have the send survey flag either Yes or No3. Let’s take Send Survey Flag has Yes. a. Find the email address exists in unsubscribe table. If it doesn’t have the email address exists in unsubscribe table. Flag return yes flag.b. If it does have a email address exists in unsubscribe table return No flag.4. Let’s take Send Survey Flag has No. a. Here it’s send survey flag is no. We don’t need to look up on the unsubscribe table just return No flag.5. If the email address does not exist in the custemaildim table find that email address exist in the unsubscribe table if it has that email Address return NO flag. If it does not exist on both tables then it return YES flag. |
|
waterduck
Aged Yak Warrior
982 Posts |
Posted - 2013-12-23 : 04:44:55
|
hey....do take note that query hint and how to query is 2 different thinghttp://technet.microsoft.com/en-us/library/ms181714.aspx |
|
|
waterduck
Aged Yak Warrior
982 Posts |
Posted - 2013-12-23 : 04:51:43
|
[code]declare @custemaildim table(emailADDr varchar(50), SendSurvey varchar)insert into @custemaildim select'some@gmail.com', 'N' union all select'exam@gmail.com', 'y' union all select'test@gmail.com', 'Y'declare @Unsubscribe table(emailADDr varchar(50), Sno int)insert into @Unsubscribe select'exam@gmail.com', 2 union all select'new1@gmail.com', 2--This is to find the email address is in custemaildimSELECT *FROM @custemaildimWHERE emailADDr = 'some@gmail.com'--This is to find the email address is in UnsubscribeIF EXISTS(SELECT * FROM @Unsubscribe WHERE emailADDr = 'some@gmail.com') SELECT 'YES'ELSE SELECT 'NO' --So now you need to think how to get this 2 thing work together[/code] |
|
|
|
|
|