I have a table with content:
I want to write a direct SQL query to select the time_delivery, where country is, for example, DK in this case.
So it should return 1-5.
I was following a tutorial: https://fishpig.co.uk/magento/tutorials/direct-sql-queries/
And tried modifying query myself like this:
$country= "DK";
$query = 'SELECT time_delivery FROM ' . $table . ' WHERE country = '
.$country . ' LIMIT 1';
But I get an error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'DK' in 'where clause'
I would assume that it has something to do with the fact the in the tutorial he uses an int but I want to use a string
DKcorresponds to a column rather than a value"DK". Your full query will look like this:SELECT time_delivery FROM (TABLE) WHERE country = DK LIMIT 1You can fix this my quoting the value using the database connector.$db->quote($country)