Forums
This topic is locked
Comparing column values in same row in a table
21 Sep 2001 20:00:14 B. B. posted:
Hello! Have a question about comparing column values within the same row on a table. A Username row on the Winners_Table has 17 columns named Week1 up to Week17 and they will update a column based on a function that determines the current week.
The values in consecutive weeks cannot equal such as if Week1 is equal to TeamA then Week2 cannot equal TeamA and an error
message will display on the page before the update to Week2 takes place.
This check is only needed for the current week and back one week. The current week is determined by the previously mentioned functioned.
What is the best way to check for this possible error condition and to display an appropriate error message or page as well? Is it efficient to have or good practice to use more than one recordset on a page that is
selecting from the same table. For example, would have recordset1 select on Username and then retrieve the Week1 column and then recordset2 select on the same Username and then retrieve the Week2 column. The columns would then be compared and if they were equal an error message would display on the
page.
Realize that this could be done by the retrieving of both Week1 and Week2 in one
recordset then doing a compare or also with a query as well. Not sure if just a query will yield the solution or recordsets with some code performing the comparison.
This check is only needed for the current week and back one week. This does not
have to be done for all weeks at one time. A separate function will determine the
current week number based on a range of dates and the current week number will
be passed somehow to the query or recordset code. Not sure how to pass it as well.
Should it be a session variable from the same page. Guess it depends on whether
the solution is manually coded or is behavior generated code.
Hope the above is described clearly. Thanks!