Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 Other Topics
 Require dynamic SQL query for a multiple criteria search page

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-10-24 : 09:19:03
Ricardo writes "I am a 3rd year university student, doing my major project.
Part of it includes a search page for the local SPCA, for users
to search for their lost animals.

I am using Frontpage 2000 with an asp connection to an access db.
I have completed my search page but have the following problems:

1) I can't use 'AND' statements for all the criteria, because
the drop-down menu's still use the default selection as
a search criteria even though the user has not selected it.
Results: in "no matches found"

2) Even when there is no value entered for the Microchip #,
the search still yields results of those animals who don't have
a value in their Microchip # field.

3)I need to create an 'AND' relationship between colour1 & colour2 without making it compulsory to select them both.

NB: Ignore the fact that 'Breed' should be compulsory, it
should only be compulsory if 'Dog' is selected from the 'Animal Type' drop-down menu.

My prototype search page can be viewed at: http://puffin.und.ac.za/group17

I need to have this project running by the 29 October
I don't know much about SQL, so if you could please
draw up a sample code that I could paste in Frontpage, I would
be grateful.

Here is the code that has been generated by frontpage thus far:

SELECT * FROM tblAnimal_Info_part1 WHERE
(Name LIKE '%::SearchName::%' AND Animal_Type = '::SearchType::' AND Sex = '::SearchSex::' AND Breed = '::SearchBreed::' OR Colour1 = '::SearchColour1::' OR Colour2 = '::SearchColour2::' OR "Location Found" LIKE '%::SearchSuburb::%' OR Microchip_No = '::Microchip_No::') ORDER BY Animal_Type ASC,Breed ASC,Sex ASC,Name ASC

NB: 'SearchDate' part of query still needs to be included.

Summary: The 'AND' based search page needs to yield specific results showing only the results matching the criteria selected. The User should also be able to select less of the criteria in order to broaden the search.

Thanks for your help, email me if you can answer this question."
   

- Advertisement -