Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / July 2005

Tip: Looking for answers? Try searching our database.

If, then, else SQL select query

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
lyric2002 - 12 Jul 2005 22:07 GMT
I would like to do a select query based on a list of if, then, else
statements. What is the syntax in an SQL select query?

Thanks in advance.
Klatuu - 12 Jul 2005 22:17 GMT
You can use the immediate if (IIF) in queries.  
My preferred approach is to create a parameter query, assign values to
variables with If Then Else and set the query's parameters with the variables.

> I would like to do a select query based on a list of if, then, else
> statements. What is the syntax in an SQL select query?
>
> Thanks in advance.
David C. Holley - 13 Jul 2005 01:20 GMT
SQL is a data access language, it is not a PROGRAMMING language. It is
not possible to put If...then...else statements into a SQL Statement
since SQL does not support If...Thens.

What are you trying to accomplish?

> I would like to do a select query based on a list of if, then, else
> statements. What is the syntax in an SQL select query?
>
> Thanks in advance.
lyric2002 - 13 Jul 2005 14:37 GMT
Basically I want it to do this:

For each row:
when table1.column1 = 'data' or table2.column1 = 'data' or table2.column2
='data' or table2.column3 = 'data' then 'constant'

I hope this is clear enough, if not let me know.
Thanks.

> SQL is a data access language, it is not a PROGRAMMING language. It is
> not possible to put If...then...else statements into a SQL Statement
[quoted text clipped - 6 lines]
> >
> > Thanks in advance.
Tim Ferguson - 13 Jul 2005 18:28 GMT
> For each row:
> when table1.column1 = 'data' or table2.column1 = 'data' or
> table2.column2 ='data' or table2.column3 = 'data' then 'constant'

Look up help for the IIF() function. But I strongly suspect a design
problem here...

B Wishes

Tim F
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.