Re: SQL to allow a "no preference (all) choice
From: Jeff Cochran (jeff.nospam_at_zina.com)
Date: 07/02/04
- Next message: Rich Palarea: "Re: SQL to allow a "no preference (all) choice"
- Previous message: Jeff Cochran: "Re: webapplication with SQL-server"
- In reply to: Rich Palarea: "SQL to allow a "no preference (all) choice"
- Next in thread: Rich Palarea: "Re: SQL to allow a "no preference (all) choice"
- Reply: Rich Palarea: "Re: SQL to allow a "no preference (all) choice"
- Reply: Rich Palarea: "Re: SQL to allow a "no preference (all) choice"
- Reply: Rich Palarea: "Re: SQL to allow a "no preference (all) choice"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 02 Jul 2004 20:17:45 GMT
On Fri, 2 Jul 2004 14:41:20 -0400, "Rich Palarea" <nospam@none.com>
wrote:
>I have an Access db and a set of .asp pages.
>
>I'd like to offer a website visitor the chance to select all records, in
>addition to being able to select the preferences they want (i.e.: no
>preference). To give you a better idea of how the sql is structured (as you
>can see, it is FrontPage generated sql, but can be edited with standard SQL
>commands):
>
>User can choose to find a group by three fields: GroupMix, MeetingDay,
>MeetingLocation from the table Smallgroups. All are dropdown fields in a
>form. GroupMix and MeetingLocation are populated by a SELECT statement to
>the Smallgroups table. MeetingDay is pre-populated with days of the week.
>
>It is easy to get "no records found" with this setup because of the limited
>number of records in the table at present. I would like the user to be
>allowed the choices of "no preference" inside of the three drop down fields.
Make "Any" an option in your drop down, then use IF/THEN statements or
CASE to build a WHERE clause in your query. Something like (watch for
code wrap):
----------------------------------------------------------
fp_sQry = "SELECT * FROM Smallgroups"
IF GroupMix <> "Any" OR MeetingDay <> "Any" OR MeetingLocation <>
"Any" THEN
fp_sQry = fp_sQry & " WHERE (status = 'open'"
IF GroupMix <> "Any" THEN
fp_sQry = fp_sQry & " AND GroupMix = '::GroupMix::'"
END IF
IF MeetingDay <> "Any" THEN
fp_sQry = fp_sQry & " AND MeetingDay = '::MeetingDay::''"
END IF
IF MeetingLocation <> "Any" THEN
fp_sQry = fp_sQry & " AND MeetingLocation =
'::MeetingLocation::''"
END IF
fp_sQry = fp_sQry & ")"
END IF
----------------------------------------------------------
Jeff
>Present SQL for the form (showing just the dropdown portion for GroupMix;
>there is a similar select for MeetingLocation further down in my page):
>
><% end if %>
><%
>fp_sQry="SELECT Distinct Smallgroups.GroupMix FROM Smallgroups ORDER BY
>GroupMix ASC"
>fp_sDefault=""
>fp_sNoRecords="No records returned."
>fp_sDataConn="GFCData"
>fp_iMaxRecords=256
>fp_iCommandType=1
>fp_iPageSize=0
>fp_fTableFormat=False
>fp_fMenuFormat=True
>fp_sMenuChoice="GroupMix"
>fp_sMenuValue="GroupMix"
>fp_sColTypes="&OrgID=3&Name=202&MeetingDay=202&MeetingLocation=202&GroupMix=
>202&MeetingTime=202&ChildrenAllowed=202&Status=202&ContactIndLabel=202&Conta
>ctHomePhone=202&ContactIndvEmail=202&"
>fp_iDisplayCols=1
>fp_fCustomQuery=False
>BOTID=0
>fp_iRegion=BOTID
>%>
>
>Present SQL for the results page:
><% end if %>
><%
>fp_sQry="SELECT * FROM Smallgroups WHERE (status = 'open' AND MeetingDay =
>'::MeetingDay::' AND GroupMix = '::GroupMix::' AND MeetingLocation =
>'::MeetingLocation::')"
>fp_sDefault=""
>fp_sNoRecords="No records returned."
>fp_sDataConn="GFCData"
>fp_iMaxRecords=256
>fp_iCommandType=1
>fp_iPageSize=0
>fp_fTableFormat=False
>fp_fMenuFormat=False
>fp_sMenuChoice=""
>fp_sMenuValue=""
>fp_sColTypes="&OrgID=3&Name=202&MeetingDay=202&MeetingLocation=202&GroupMix=
>202&MeetingTime=202&ChildrenAllowed=202&Status=202&ContactIndLabel=202&Conta
>ctHomePhone=202&ContactIndvEmail=202&"
>fp_iDisplayCols=11
>fp_fCustomQuery=True
>BOTID=0
>fp_iRegion=BOTID
>%>
>
>Present working page: http://smallgroups.gfc.org/IDsite/locator.asp
>
>Thanks!
>Rich
>
- Next message: Rich Palarea: "Re: SQL to allow a "no preference (all) choice"
- Previous message: Jeff Cochran: "Re: webapplication with SQL-server"
- In reply to: Rich Palarea: "SQL to allow a "no preference (all) choice"
- Next in thread: Rich Palarea: "Re: SQL to allow a "no preference (all) choice"
- Reply: Rich Palarea: "Re: SQL to allow a "no preference (all) choice"
- Reply: Rich Palarea: "Re: SQL to allow a "no preference (all) choice"
- Reply: Rich Palarea: "Re: SQL to allow a "no preference (all) choice"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|