Illegal mix of collations for operation 'case'<p><font color="red">SQL: </font>SELECT properties.id, property_unique_id,type,user_id, description, reference_number, features, lease_avail_date, rental_pw, security_bond, created_at,
		(SELECT tblPropertyType.strPropertyName FROM property_metadata.tblPropertyType WHERE tblPropertyType.intPropertyNum = properties.property_type LIMIT 1) AS property_type , 
		  latitude, longitude, (garage + carport) as carspaces, carport, garage, off_street_park, bedrooms, bathrooms, headline, building_size, land_size, vr_tour1, vr_tour2,
		  (SELECT councils.name FROM suburbs.councils WHERE councils.id = properties.council_id LIMIT 1) AS municipality, 
		  CONCAT('http://www.aireysinletrealestate.com.au/',properties.id) as url,price_display,
		   (SELECT CASE 
		  			WHEN properties.price_display = 1 
						THEN CONCAT('$',FORMAT(properties.price , 0))
					WHEN properties.price_display = 2 
						THEN properties.price_display_value						
					WHEN properties.type LIKE '%lease%' 
						THEN CONCAT('$',properties.price ,' per week') 
					ELSE '' 
			END  ) AS price_text, price,
			
			
			DATE_FORMAT(properties.auction_date,'%a %D of %b %y') as auction_date, DATE_FORMAT(properties.auction_time,'%h:%i%p') as auction_time,
			
			(SELECT CASE WHEN properties.status = '2' THEN CONCAT( 'http://propertylister.com.au/xml/uploads/overlay/' , sold_overlay , '_200x150.png')
			WHEN properties.status = '4' THEN CONCAT( 'http://propertylister.com.au/xml/uploads/overlay/' , contract_overlay , '_200x150.png' ) 
			WHEN properties.status = '6' THEN CONCAT( 'http://propertylister.com.au/xml/uploads/overlay/' , lease_overlay , '_200x150.png' ) 
			ELSE '' END 
			FROM agentlog_system.offices WHERE offices.id = properties.office_id ) AS photo_overlay,		
			
									
			CONCAT( 
				'http://propertylister.com.au/xml/uploads/photos', '/', properties.id , '/', properties.id , '_' ,
				(SELECT photos.hashed_name FROM agentlog_system.photos WHERE photos.property_id = properties.id ORDER BY `order` ASC LIMIT 1 ) ,
				'_200x150.jpg'
				) AS photo_url,
				
			 
		  
		   (SELECT CASE 
		  			WHEN properties.display_add = 1 THEN  
						CONCAT( IF ( (TRIM(properties.unit_number) IS NULL) OR (TRIM(properties.unit_number) = '') , '', CONCAT(TRIM(properties.unit_number),'/')  ), properties.street_number,' ',properties.street,' ',properties.street_type)
					WHEN properties.display_add = 2 THEN 
						properties.suburb 
					ELSE '' 
			END ) AS address, properties.state, properties.suburb , postcode
		  FROM agentlog_system.properties
		  
		  WHERE 
		  
		  properties.type IN ('ResidentialSale' , 'CommercialSale') AND DATEDIFF(CURDATE(),`created_at`) <= 7 AND  properties.office_id IN (166) AND properties.status IN ( '1', '2', '4', '6' )		  
		  AND ((`sold_at` IS NULL) OR (DATEDIFF(CURDATE(),`sold_at`) <= '7'))
		  AND ((`leased_at` IS NULL) OR (DATEDIFF(CURDATE(),`leased_at`) <= '7'))
		  AND ((`contract_at` IS NULL) OR (DATEDIFF(CURDATE(),`contract_at`) <= ''))
		  AND properties.deleted_at IS NULL 
		  		  
		   ORDER BY `id` 
													
		  </p>