Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to compare values in an IF statement

Guest
Jan 11, 2008 Jan 11, 2008
Hi --
I have used a JOIN and COUNT SQL statement to find out a value I called "UniqueReg". It is a number. I want to compare that UniqueReg number to another value (also a number) in a field in my database using an IF statement, but it is not working properly.

Here is the statement:
<% if (rs_LeftJoin.fields.item("UniqueReg").value > "15") { %>
Registrations are greater than 15
<% } %>

Any ideas? Thanks.
TOPICS
Server side applications
291
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 11, 2008 Jan 11, 2008
jennivazquez wrote:
> Here is the statement:
> <% if (rs_LeftJoin.fields.item("UniqueReg").value > "15") { %>

Try it with 15 not "15".


--
Danilo Celic
| Extending Knowledge Daily : http://CommunityMX.com/
| Adobe Community Expert
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 11, 2008 Jan 11, 2008
No, didn't work...

I got the "UniqueReg" with this SQL statement:

SELECT LocationName, DaysTimes, count(ProgLocID_FK) AS UniqueReg
FROM ProgramLocations
LEFT JOIN GirlRegistration
ON ProgramLocations.ProgLocID = GirlRegistration.ProgLocID_FK
GROUP By ProgramLocations.LocationName, ProgramLocations.DaysTimes

and from it I am using this IF statement:
<% if (rs_LeftJoin.fields.item("UniqueReg").value > "15") { %>

Is "UniqueReg" not seen as a number, maybe?

Thanks for your reply --



Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 11, 2008 Jan 11, 2008
LATEST
jennivazquez wrote:
> No, didn't work...
>
> I got the "UniqueReg" with this SQL statement:
>
> SELECT LocationName, DaysTimes, count(ProgLocID_FK) AS UniqueReg
> FROM ProgramLocations
> LEFT JOIN GirlRegistration
> ON ProgramLocations.ProgLocID = GirlRegistration.ProgLocID_FK
> GROUP By ProgramLocations.LocationName, ProgramLocations.DaysTimes
>
> and from it I am using this IF statement:
> <% if (rs_LeftJoin.fields.item("UniqueReg").value > "15") { %>
>
> Is "UniqueReg" not seen as a number, maybe?

I just tried with a value that was a number (20) and compared it to "15" and it evaluated to true. I also tried it with the result of a count(ID) (20312) from a recordset and it too evaluated to true. FWIW, you should not use a string when you want to compare numeric values. Do so is relying on conversion of value types and you may not get what you wany.

Have you output that value to ensure that you're getting the number you think you should be getting? Beyond that, if you have a number and that number is greater than 15 and you're not gettting that evaluated as true, then something weird is going on on your server.


--
Danilo Celic
| Extending Knowledge Daily : http://CommunityMX.com/
| Adobe Community Expert
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines