catfan / Medoo

The lightweight PHP database framework to accelerate the development.
https://medoo.in
MIT License
4.84k stars 1.15k forks source link

SQL CONCAT statement fails if it includes a " " #838

Closed stephendwolff closed 5 years ago

stephendwolff commented 5 years ago

If a space is added using CONCAT between two fields, it causes a query to fail. ie:

SELECT p.ID, f.Name, p.Subname, CONCAT(f.Code, " ", p.SubCode) FROM p LEFT JOIN f ON f.ID = p.F_ID

Where as this works (without the " ")

SELECT p.ID, f.Name, p.Subname, CONCAT(f.Code, p.SubCode) FROM p LEFT JOIN f ON f.ID = p.F_ID

Information

Expected output I would expect the query to return two fields joined, with a space between in a single column, ie:

(1, "B C"), (2, "D E"), (3, "F G"), (4, "H I"),

catfan commented 5 years ago

You may use raw object to this case. https://medoo.in/api/raw

stephendwolff commented 5 years ago

Brilliant thanks. Just realised the query is a prepared statement. (Which I should have known).