Try it with DB::unprepared()
Jul 11, 2017
3
Level 1
MySQL Query Prepared Statement to Laravel
I spent hours making this query right using phpMyAdmin and when I was already going to transfer it on my laravel project, it says there is an error, and I really don't understand what the error is.
SELECT GROUP_CONCAT(DISTINCT CONCAT(
'SUM( CASE WHEN rate_sub_type = ''',rate_sub_type,''' THEN rate END ) AS rate_sub_type'
)
) INTO @sql
FROM rate_sub_types;
SET @query = CONCAT('SELECT rate_type, name, ', @sql, '
FROM rate_types a, rate_sub_types b, rates c
where a.id=b.rate_type_id and b.id=c.rate_sub_type_id and c.amenity_id is null GROUP BY rate_type, name
UNION
SELECT rate_type, d.name, ', @sql, '
FROM rate_types a, rate_sub_types b, rates c, amenities d
where a.id=b.rate_type_id and b.id=c.rate_sub_type_id and d.id=c.amenity_id
GROUP BY rate_type, d.name');
PREPARE stmt FROM @query;
EXECUTE stmt;
This is how i put it on laravel...
These are the errors...
http://imgur.com/DhHwb9R http://imgur.com/lhLrK2m
Anyone who could help me please? Thank you so much
Please or to participate in this conversation.