I’m using a prepared statement with this SQL code:
SELECT `name` FROM `securities` WHERE `symbol`=? AND `type`=`C`
but I keep getting this error when I execute it:
Column not found: 1054 Unknown column 'C' in 'where clause'
The table is set up like this:
+--------+-----------------------+------+------+
| symbol | name | type | used |
+--------+-----------------------+------+------+
| AED | UAE Dirham | C | 0 |
| ALL | Albanian Lek | C | 0 |
| ANG | Neth Antilles Guilder | C | 0 |
| ARS | Argentine Peso | C | 0 |
| AUD | Australian Dollar | C | 0 |
| AWG | Aruba Florin | C | 0 |
| BBD | Barbados Dollar | C | 0 |
| BDT | Bangladesh Taka | C | 0 |
| BGN | Bulgarian Lev | C | 0 |
| BHD | Bahraini Dinar | C | 0 |
+--------+-----------------------+------+------+
and I’m trying to query just the name from it. How can I fix this error? The code that involves binding a value is too long to post, but basically, it executes the prepared statement with array($symbol). Is there an SQL error that I’m missing?
You have the value
Cenclosed in backticks. This should only be done for column and table names, not values.Change it to quotes and it should work: