Well, firstly, I am creating a query to search for MLS data, which was provided in the form of a MySQL database. Therefore, I do not have control over the data format, and therefore I believe that I need to do a lot of casting to get the data in a manageable form. SQL error.
MySQL server version for the right syntax to use near ' DECIMAL(2, 1)) / .5,
CAST(idx1.full_baths, DECIMAL(2, 1))), DECIMAL(2, 1)) AS b' at line 1
I looked at the error code and it sends me to a reserved page of words, but I can not identify the reserved words.
and now sql
(all fields initially VARCHAR)
SELECT idx_common.mls_no AS mls_no,
CONCAT_WS(" ", idx_common.street_no, idx_common.street_direction, idx_common.street_name) AS address,
idx_common.city AS city,
idx_common.state AS state,
idx_common.total_sqft AS total_sqft,
idx_common.asking_price AS price,
idx1.bedrooms AS bedrooms,
CAST(
SUM(
(CAST(idx1.half_baths, DECIMAL(2, 1)) / .5),
CAST(idx1.full_bath, DECIMAL(2, 1))
),
DECIMAL(2, 1)
) AS bathrooms,
idx1.residential_prop_type AS type,
"Listing Agent" AS agent
FROM (idx_common)
JOIN idx1 ON idx_common.mls_no = idx1.mls_no
WHERE `idx_common`.`mls_no` = 'query'
OR idx_common.zip LIKE '%query%'
OR idx_common.city LIKE '%query%'