Solved

What does it mean this access query

Posted on 2008-10-20
12
685 Views
Last Modified: 2013-11-28
IIf([T_FPtr_GeneralSearch].[PromoPeriod]="Period",1,IIf([T_FPtr_GeneralSearch].[PromoPeriod]=[T_100_q010_PromoTitleandDetailsAsOne_SELECT].[T_OUTPUT_PromoChosenAtEntry_MAIN].[promo_period],1,0))
0
Comment
Question by:jaisonshereen
  • 5
  • 5
  • 2
12 Comments
 
LVL 9

Accepted Solution

by:
jamesgu earned 250 total points
ID: 22760333
IIf([T_FPtr_GeneralSearch].[PromoPeriod]="Period",1,

IIf([T_FPtr_GeneralSearch].[PromoPeriod]=[T_100_q010_PromoTitleandDetailsAsOne_SELECT].[T_OUTPUT_PromoChosenAtEntry_MAIN].[promo_period],1,0))

if T_FPtr_GeneralSearch].[PromoPeriod]="Period, the value is 1
else if T_FPtr_GeneralSearch].[PromoPeriod]=[T_100_q010_PromoTitleandDetailsAsOne_SELECT].[T_OUTPUT_PromoChosenAtEntry_MAIN].[promo_period]
else the vlaue is 0

0
 

Author Comment

by:jaisonshereen
ID: 22760429
is this assigning values 0 or 1 to a table?
0
 
LVL 45

Expert Comment

by:aikimark
ID: 22760560
As VB code (see snippet)

Note: your SQL would be easier to understand if you used aliases for your tables.
If T_FPtr_GeneralSearch].[PromoPeriod] = "Period" Then
   Value = 1
 
ElseIf T_FPtr_GeneralSearch].[PromoPeriod] = T_100_q010_PromoTitleandDetailsAsOne_SELECT].[T_OUTPUT_PromoChosenAtEntry_MAIN].[promo_period] Then
   Value = 1
 
Else
   Value = 0
 
End If

Open in new window

0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 9

Expert Comment

by:jamesgu
ID: 22760617
it's either 0 or 1 based on the current  value of

T_FPtr_GeneralSearch].[PromoPeriod]

T_FPtr_GeneralSearch].[PromoPeriod]
and [T_100_q010_PromoTitleandDetailsAsOne_SELECT].[T_OUTPUT_PromoChosenAtEntry_MAIN].[promo_period]

if T_FPtr_GeneralSearch].[PromoPeriod] = "Period' or
T_FPtr_GeneralSearch].[PromoPeriod] = [T_100_q010_PromoTitleandDetailsAsOne_SELECT].[T_OUTPUT_PromoChosenAtEntry_MAIN].[promo_period], then the value of the statement is 1,
0 otherwise
0
 

Author Comment

by:jaisonshereen
ID: 22773567
what will be this 0 and 1 is used for?
0
 
LVL 45

Expert Comment

by:aikimark
ID: 22773578
since you haven't shown us the entire SQL statement and the code that invokes the SQL, we don't know.
0
 

Author Comment

by:jaisonshereen
ID: 22773588
this is the query
T-001-SearchCriteria.jpg
0
 
LVL 45

Expert Comment

by:aikimark
ID: 22776492
I asked to see the SQL, not a screen shot of the query builder.  

Also, what about the code that invokes it?  If you need to know HOW the 0/1 value is used, it can only be answered by examining the invoking/consuming routines.  For all I know, these values might be bound to a checkbox control somewhere.
0
 

Author Comment

by:jaisonshereen
ID: 22776538
See this
SELECT T_100_q010_PromoTitleandDetailsAsOne_SELECT.T_OUTPUT_PromoChosenAtEntry_MAIN.Temp_PromoID AS Temp_PromoID
FROM T_FPtr_GeneralSearch, T_100_q010_PromoTitleandDetailsAsOne_SELECT
WHERE (((IIf([T_FPtr_GeneralSearch].[status]="Status",1,IIf([T_FPtr_GeneralSearch].[Status]=[T_100_q010_PromoTitleandDetailsAsOne_SELECT].[proceed],1,0)))=1) AND ((IIf([T_FPtr_GeneralSearch].[PromoPeriod]="Period",1,IIf([T_FPtr_GeneralSearch].[PromoPeriod]=[T_100_q010_PromoTitleandDetailsAsOne_SELECT].[T_OUTPUT_PromoChosenAtEntry_MAIN].[promo_period],1,0)))=1) AND ((IIf([T_FPtr_GeneralSearch].[location]="location",1,IIf([T_FPtr_GeneralSearch].[location]=[T_100_q010_PromoTitleandDetailsAsOne_SELECT].[T_OUTPUT_PromoChosenAtEntry_MAIN].[location],1,0)))=1) AND ((IIf(Val([T_FPtr_GeneralSearch].[Year])=0,1,IIf(Val([T_FPtr_GeneralSearch].[year])=([T_100_q010_PromoTitleandDetailsAsOne_SELECT].[T_OUTPUT_PromoChosenAtEntry_MAIN].[year]),1,0)))=1) AND ((IIf(([T_FPtr_GeneralSearch].[StartDate])="Start Date",1,IIf(DateValue([T_FPtr_GeneralSearch].[StartDate])=([T_100_q010_PromoTitleandDetailsAsOne_SELECT].[PPStartDate]),1,0)))=1) AND ((IIf([T_FPtr_GeneralSearch].[TempPromoID]=0,1,IIf([T_FPtr_GeneralSearch].[TempPromoID]=[T_100_q010_PromoTitleandDetailsAsOne_SELECT].[T_OUTPUT_PromoChosenAtEntry_MAIN].[Temp_PromoID],1,0)))=1) AND ((IIf([T_FPtr_GeneralSearch].[CatID]=0,1,IIf([T_FPtr_GeneralSearch].[CatID]=[T_100_q010_PromoTitleandDetailsAsOne_SELECT].[CategoryID],1,0)))=1) AND ((IIf([T_FPtr_GeneralSearch].[CategoryMan]="Category Manager",1,IIf([T_FPtr_GeneralSearch].[CategoryMan]=[T_100_q010_PromoTitleandDetailsAsOne_SELECT].[Category_Man],1,0)))=1) AND ((IIf([T_FPtr_GeneralSearch].[EnteredBy]="Log on",1,IIf([T_FPtr_GeneralSearch].[EnteredBy]=[T_100_q010_PromoTitleandDetailsAsOne_SELECT].[T_OUTPUT_PromoChosenAtEntry_MAIN].[EnteredBy],1,0)))=1) AND ((IIf([T_FPtr_GeneralSearch].[Article]=0,1,IIf([T_FPtr_GeneralSearch].[Article]=[T_100_q010_PromoTitleandDetailsAsOne_SELECT].[Article],1,0)))=1))
GROUP BY T_100_q010_PromoTitleandDetailsAsOne_SELECT.T_OUTPUT_PromoChosenAtEntry_MAIN.Temp_PromoID;

Open in new window

0
 
LVL 45

Expert Comment

by:aikimark
ID: 22777069
Within the Where clause, the 0 and 1 values are used as a replacement for a Boolean OR operator.  The Where clause should be written as shown in the snippet.


WHERE ([GenSrch].[status]="Status" OR [GenSrch].[Status]=[T_100].[proceed])
AND ([GenSrch].[PromoPeriod]="Period" OR [GenSrch].[PromoPeriod]=[T_100].[T_OUTPUT_PromoChosenAtEntry_MAIN].[promo_period])
AND ([GenSrch].[location]="location" OR [GenSrch].[location]=[T_100].[T_OUTPUT_PromoChosenAtEntry_MAIN].[location])
AND (Val([GenSrch].[Year])=0 OR Val([GenSrch].[year])=([T_100].[T_OUTPUT_PromoChosenAtEntry_MAIN].[year])
AND ([GenSrch].[StartDate])="Start Date" OR DateValue([GenSrch].[StartDate])=([T_100].[PPStartDate])
AND ([GenSrch].[TempPromoID]=0 OR [GenSrch].[TempPromoID]=[T_100].[T_OUTPUT_PromoChosenAtEntry_MAIN].[Temp_PromoID])
AND ([GenSrch].[CatID]=0 OR [GenSrch].[CatID]=[T_100].[CategoryID])
AND ([GenSrch].[CategoryMan]="Category Manager" OR [GenSrch].[CategoryMan]=[T_100].[Category_Man])
AND ([GenSrch].[EnteredBy]="Log on" OR [GenSrch].[EnteredBy]=[T_100].[T_OUTPUT_PromoChosenAtEntry_MAIN].[EnteredBy])
AND ([GenSrch].[Article]=0 OR [GenSrch].[Article]=[T_100].[Article])

Open in new window

0
 
LVL 45

Assisted Solution

by:aikimark
aikimark earned 250 total points
ID: 22777372
Let me show all the SQL, since I aliased the tables
SELECT T_100.T_OUTPUT_PromoChosenAtEntry_MAIN.Temp_PromoID AS Temp_PromoID
 
FROM T_FPtr_GeneralSearch As GenSrch, T_100_q010_PromoTitleandDetailsAsOne_SELECT As T_100
 
WHERE ([GenSrch].[status]="Status" OR [GenSrch].[Status]=[T_100].[proceed])
AND ([GenSrch].[PromoPeriod]="Period" OR [GenSrch].[PromoPeriod]=[T_100].[T_OUTPUT_PromoChosenAtEntry_MAIN].[promo_period])
AND ([GenSrch].[location]="location" OR [GenSrch].[location]=[T_100].[T_OUTPUT_PromoChosenAtEntry_MAIN].[location])
AND (Val([GenSrch].[Year])=0 OR Val([GenSrch].[year])=([T_100].[T_OUTPUT_PromoChosenAtEntry_MAIN].[year])
AND ([GenSrch].[StartDate])="Start Date" OR DateValue([GenSrch].[StartDate])=([T_100].[PPStartDate])
AND ([GenSrch].[TempPromoID]=0 OR [GenSrch].[TempPromoID]=[T_100].[T_OUTPUT_PromoChosenAtEntry_MAIN].[Temp_PromoID])
AND ([GenSrch].[CatID]=0 OR [GenSrch].[CatID]=[T_100].[CategoryID])
AND ([GenSrch].[CategoryMan]="Category Manager" OR [GenSrch].[CategoryMan]=[T_100].[Category_Man])
AND ([GenSrch].[EnteredBy]="Log on" OR [GenSrch].[EnteredBy]=[T_100].[T_OUTPUT_PromoChosenAtEntry_MAIN].[EnteredBy])
AND ([GenSrch].[Article]=0 OR [GenSrch].[Article]=[T_100].[Article])
 
GROUP BY T_100.T_OUTPUT_PromoChosenAtEntry_MAIN.Temp_PromoID; 

Open in new window

0
 

Author Closing Comment

by:jaisonshereen
ID: 31507923
Thanks a lot!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question