Skip to main content
Inspiring
June 7, 2007
Question

ASP/VB If ElseIf End If

  • June 7, 2007
  • 3 replies
  • 288 views
Does anyone know how to re-write this so that it actually works? Can't seem
to find anythingthat gives me a solid enough clue even if I simplify it.

Thanks,
Craig

SELECT *
FROM notice
IF jobtype = 'MMColParam' AND onoff=-1 AND ndate >= date() THEN
ORDER BY ndate ASC
ELSEIF 'MMColParam'='old' AND onoff=-1 AND ndate <= date() THEN
ORDER BY ndate DESC
END IF


This topic has been closed for replies.

3 replies

Inspiring
June 11, 2007
Craig,

Are you using TSQL?

David Pearson
Inspiring
June 7, 2007
> SELECT *
> FROM notice
> IF jobtype = 'MMColParam' AND onoff=-1 AND ndate >= date() THEN
> ORDER BY ndate ASC
> ELSEIF 'MMColParam'='old' AND onoff=-1 AND ndate <= date() THEN
> ORDER BY ndate DESC
> END IF

Lionstone's solution probably is the most proper (ie, look up proper CASE
syntax in SQL) but you could easily do this with some ASP variables:

dim OrderByClause as string.

If whatever... then
OrderByClause = "order by whatever"
else
OrderByClause = "order by the other thing"
end if

SQLstring = "Select Whatever From whatever" & OrderByClause

-Darrel


Inspiring
June 7, 2007
Probably because queries are part of the database and as such are written in
SQL, not VBScript.
Look up the CASE statement. In an SQL resource, not a VB site.


"Craig" <csintheuk@hotmail.com> wrote in message
news:f49ei8$21p$1@forums.macromedia.com...
> Does anyone know how to re-write this so that it actually works? Can't
> seem to find anythingthat gives me a solid enough clue even if I simplify
> it.
>
> Thanks,
> Craig
>
> SELECT *
> FROM notice
> IF jobtype = 'MMColParam' AND onoff=-1 AND ndate >= date() THEN
> ORDER BY ndate ASC
> ELSEIF 'MMColParam'='old' AND onoff=-1 AND ndate <= date() THEN
> ORDER BY ndate DESC
> END IF
>