HI,
Just wanted to run this code by you all. I have a form that displays the details of 1 record. The ID is passed on from another cfm page and if they is nothing passed it uses ID 30. Then I have 3 querys. 1 that gets all the fields for the passed or default record and 2 that display other vehicles of the same Make and Model.
I need another query that will give me all vehicles that are within +-$2000 and seem to be having problems figuring out how to do it.
After I do that I will have 4 different querys. Is this the right way to do things.
Here is the +-$2000 that I have been trying to get to work:
Can some one point me in the right direction here?
newcow
This is the working 3 querys:
Just wanted to run this code by you all. I have a form that displays the details of 1 record. The ID is passed on from another cfm page and if they is nothing passed it uses ID 30. Then I have 3 querys. 1 that gets all the fields for the passed or default record and 2 that display other vehicles of the same Make and Model.
I need another query that will give me all vehicles that are within +-$2000 and seem to be having problems figuring out how to do it.
After I do that I will have 4 different querys. Is this the right way to do things.
Here is the +-$2000 that I have been trying to get to work:
Can some one point me in the right direction here?
newcow
Code:
<cfquery name="CarPrice" datasource="cardata">
SELECT tblCars.*, tblDealers.DealerURL, tblDealers.DealerFullName, tblVNs.VName
FROM (tblCars INNER JOIN tblVNs ON tblCars.VN=tblVNs.VN) INNER JOIN tblDealers
ON tblCars.Dealer=tblDealers.Dealer
WHERE tblCars.ID <> <cfqueryparam value="#url.id#" cfsqltype="cf_sql_integer">
AND tblCars.Model = <cfqueryparam value="#Price#" cfsqltype = "cf_sql_varchar">
ORDER BY tblCars.Model, tblCars.Year
</cfquery>
This is the working 3 querys:
Code:
<!---Set default ID = to '30' --->
<cfparam name="url.id" default="30">
<!---Query returning search results --->
<cfquery name="CarQuery" dataSource="Cardata">
SELECT tblCars.*, tblDealers.DealerURL, tblDealers.DealerFullName, tblVNs.VName
FROM (tblCars INNER JOIN tblVNs ON tblCars.VN=tblVNs.VN) INNER JOIN tblDealers
ON tblCars.Dealer=tblDealers.Dealer
<cfif IsDefined("URL.ID")>
WHERE tblCars.ID = <cfqueryparam value="#url.id#" cfsqltype = "cf_sql_integer">
</cfif>
</cfquery>
<cfset Make = CarQuery.Make>
<cfset Model = CarQuery.Model>
<cfset carID = CarQuery.ID>
<cfset Price = CarQuery.Price>
<cfquery name="CarModel" datasource="cardata">
SELECT tblCars.*, tblDealers.DealerURL, tblDealers.DealerFullName, tblVNs.VName
FROM (tblCars INNER JOIN tblVNs ON tblCars.VN=tblVNs.VN) INNER JOIN tblDealers
ON tblCars.Dealer=tblDealers.Dealer
WHERE tblCars.ID <> <cfqueryparam value="#url.id#" cfsqltype="cf_sql_integer">
AND tblCars.Model = <cfqueryparam value="#Model#" cfsqltype = "cf_sql_varchar">
ORDER BY tblCars.Model, tblCars.Year
</cfquery>
<cfquery name="CarMake" datasource="cardata">
SELECT tblCars.*, tblDealers.DealerURL, tblDealers.DealerFullName, tblVNs.VName
FROM (tblCars INNER JOIN tblVNs ON tblCars.VN=tblVNs.VN) INNER JOIN tblDealers
ON tblCars.Dealer=tblDealers.Dealer
WHERE tblCars.ID <> <cfqueryparam value="#url.id#" cfsqltype="cf_sql_integer">
AND tblCars.Make = <cfqueryparam value="#Make#" cfsqltype = "cf_sql_varchar">
ORDER BY tblCars.Model, tblCars.Year
</cfquery>
<!---Query returning search results