pda4me
asked on
Rewrite MySQL query to make it more efficient/easier in PHP
I am trying to pull lat/long from a table using a share ID from another. I got the query to work like this but it sure seem clunky...can someone give me a rewritten sample of a better way to execute this query to achieve the same result?
$query = "SELECT Residential_RESI.sMLSNumber, Residential_RESI.sLegalDescription, Residential_RESI.sCity, Residential_RESI.sState, Residential_RESI.sListPrice, Residential_RESI.sSquareFootage, Residential_RESI.sBedrooms, Residential_RESI.sTotalBaths, Residential_RESI.sAgentFirstName, Residential_RESI.sAgentLastName, Residential_RESI.sAgentPhone, Residential_RESI.sListAgentEmail, Residential_RESI.sMLSNumber, Residential_RESI.sStatus, Residential_RESI.sOfficeLong, Residential_RESI.sOfficePhone1, Residential_RESI.sOfficeAddress, Residential_RESI.sMarketingRemarks, Residential_RESI.sMasterHOAFee, Residential_RESI.sTaxes, Residential_RESI.sTaxYear, Residential_RESI.sTotalTaxBill, Residential_RESI.sAssessmentFees, Residential_RESI.sWater, Residential_RESI.sSewer, Residential_RESI.sRegionShortName, Residential_RESI.sStreetFullName, Residential_RESI.sAgentFaxPhone, Residential_RESI.sAgentPictureFile, Residential_RESI.sAgentWebSite, Residential_RESI.sDOM, Residential_RESI.sPricePerSquareFoot, property_coordinates.sLatitude, property_coordinates.sLongitude, property_coordinates.sMLSNumber FROM Residential_RESI, property_coordinates
WHERE
Residential_RESI.sMLSNumber=property_coordinates.sMLSNumber
AND sLatitude is not NULL and sLatitude != ''
and sLongitude is not NULL and sLongitude != ''";
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
@aarontomosky I was just going over some of my comments and caught your comment above (*). I agree whole-heartedly, but still so many people do this. It creates havoc when there are added fields are the order of the fields is changed.
ASKER