Page 1 of 1

Help with SQL query

Posted: Fri Oct 22, 2004 3:34 am
by C++Casey
Hi

I have a database that has a column named "SubCategory". Within the subcategory column there are 3 fields (Banks, Lenders, Realtors)I'm passing an URL parameter and what I'm trying to do is select certain fields only if the SubCategory ='Realtors' and the BankLocation='URL Parameter value"

So here is the query I have:

Code: Select all

SELECT username, company, categories, profile, email
FROM freelancers_programmers
WHERE freelancers_programmers.SubCategory = 'Realtor' AND BankLocation = 'colname'
The 'colname' is a variable whose name is 'colname' has a default value of 1, and a runtime value of $_GET['BankLocation'] and it carries of the value of the selected state when passed

The problem I'm having is that the query isn't filtering the SubCategory='Realtors'....the search results come back with not only 'Realtors', but 'Banks' and 'Lenders' as well. I only want 'Realtors' whose 'BankLocation' is passed in the search.

If you need to see a live example visit
http://www.searchbanks.com//realtors.php

and use the "Quick Search by States" section...Florida has the 'Realtor' and 'Alabama' has a lender but if you choose 'Alabama' the lender comes back in the search result....that shouldn't happen because I want to limit the search results on this page to 'Realtors' only for the selected state.

Thanks for your time and any advice

Posted: Fri Oct 22, 2004 9:42 am
by lostboy
If the other two shouldn't have values, then check to see if they're null in the query