Thanks Mike for your help.
I'll give you a breakdown of what each field contains:
mls_listings_images TABLE:
c1 = unique id
c2 = Street Address
c3 = City
c4 = List Price
c5 = Bedrooms
c6 = Baths
c7 = Zipcode
c8 = State
c9 = Description of Property
c10 = Lease Option (ended up not using it yet though)
c11 = LotSize Square Feet
c12 = Garage
c13 = View
c14 = Pool
c15 = Status Change (not used yet)
c16 = not used
c17 = Building Size
mls_listings_images:
c1 = unique id
c2 = unused
c3 = image location
Here are my answers to you questions / suggestions:
using a GROUP BY clause when it's not required
- I couldn't find another way to get the listings to tie into the listings images to be displayed once. Before using GROUP BY the listings were being displayed twice or more. For instance, if one listing had three images, three duplicate listings would be displayed rather than one listing with three images.
putting wilcards around your unique id looks very wrong - c1 LIKE '%{$_GET['uniqueid']}%') - this will result in a table scan each time and ids like 99 will match against ids 99, 199, 299, 991 etc.
- When I remove the wildcards, I get no results and nothing seems to match up for the query.
the code after the IN clause is a mess - what on earth are you trying to do there?
The IN clause was meant so that is a user checked one of the cities listed (in the form) that query would get activated. One of the cities contains zip codes that get passed (zipwestla) because there are multiple cities that are going to be queried rather than one (like santamonica). Also unique id is a field that the user can type in the unique key rather than going through the search to which it will display that result. Same with bed and baths. How would you do this differently?
the first part of your where clause has (SELECT DISTINCT mls_listings.c1 = mls_listings_images.c1) which seems nonsensical.
I used this because DISTINCT was supposed to only return one result and not duplicates as in the case of two images...
you could work on your field names (c1 ... c9) to give them a little more meaning.
I will do that, thank you.
what happens if PHP doesn't have a value for any of these parameters ie ehat happens if beds is left blank in (mls_listings.c5 >= '{$_GET['beds']}')
- Everything seems to work just fine when it's blank.
----
I answered your questions and don't take it as if I'm not up for help, since that's the whole reason I'm here. I'm just explaining why I did what I did and obviously it's at the top of the learning curve at the moment.
Thanks and I look forward to hearing your suggestions.