Search Query (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


pazafuera -> Search Query (2/9/2008 1:31:20)

Hello Everybody!

I AM GOING CRAZY HERE! I'm not sure why I can't figure this out, but it's not working.

Rentals Table contains the following field as criteria:

City (text), Bedrooms (number), Bathrooms(number), Porch (text), Patio (text), Pool (text)

The query should find all rentals in the city chosen, with the number of bathrooms & bedrooms chosen, and if the Porch, Patio and Pool options are chosen, then rentals with those options are pulled.

This is what I have:

fp_sQry="SELECT * FROM tblRentals WHERE (RentalCity LIKE '%::RentalCity::%' AND RentalBedrooms >= ::RentalBedrooms:: AND RentalBathrooms >= ::RentalBathrooms:: AND Patio LIKE '::Patio::' AND Pool LIKE '::Pool::' AND Porch LIKE '::Porch::') ORDER BY RentalID DESC"

fp_sDefault="RentalCity=&RentalBedrooms=0&RentalBathrooms=0&Patio=&Pool=&Porch="


When I do a search, and leave the Porch, Patio and Pool options unchecked, it pulls no records. What I want it to do is pull all records, regardless of whether or not they include a porch, patio or pool. If the checkbox "Porch" is checked, THEN only the records with porches will be pulled.

Does that makes sense? Why will this not work!!!!?!

Thanks in advance.




codenamebill26 -> RE: Search Query (2/9/2008 4:24:23)

this is a shot in the dark but im pretty sure you cant use the * on this so try making it look more like this



fp_sQry="SELECT City , Bedrooms, Porch, Patio, Pool FROM Rentals WHERE (Rental.City LIKE '%::RentalCity::%' AND Rental.Bedrooms >= ::RentalBedrooms:: AND Rental.Bathrooms >= ::RentalBathrooms:: AND Patio LIKE '::Patio::' AND Pool LIKE '::Pool::' AND Porch LIKE '::Porch::') ORDER BY Rental.ID DESC"



i use a access driver not mysql so im not sure really if this will even help.............




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.0625