Thanks a lot Brett. That was exactly what I was looking for and it seems to work great. You seem to be real handy with SQL so maybe you can also help me figure this out.
I need to do a Join and I really have no clue about Joins...Inner outer etc..
I have a tblVehicles which has all the Vehicle info. It also has a DealerID which relates to the tblDealers that has all the info for each dealer. In the tblDealers is a field called DealerState.
In my SQL I need to do a search for a certain model car which is in the tblVehicles and I also need to search by State, which is in the tblDealers.
How would I go about doing a Join on those two tables to ge the need results?
Here is an example of the current SQL I am using....what you gave me.
$sql = "SELECT * FROM tblVehicles WHERE 1=1 "; //always true but gives you the intinial WHERE.
$sql .= ($State != 'Any') ? " AND State= '$State'" : "";
$sql .= ($Model != 'All') ? " AND Model= '$Model'" : "";
$sql .= " ORDER BY $Order LIMIT $Offset,$Limit";
Currently this gives an error because there is no State field in the tblVehicles.
I am thinking it should look something like
$sql = "SELECT * FROM tblVehicles INNER JOIN ON tblDealers WHERE 1=1 "; //always true but gives you the intinial WHERE.
$sql .= ($State != 'Any') ? " AND State= '$State'" : "";
$sql .= ($Model != 'All') ? " AND Model= '$Model'" : "";
$sql .= " ORDER BY $Order LIMIT $Offset,$Limit";
But of course that is also wrong.
Thanks for the help.😃