Skip to content
Advertisement

Using Prepared Statements to set Table Name

I’m trying to use prepared statements to set a table name to select data from, but I keep getting an error when I execute the query.

The error and sample code is displayed below.

JavaScript

Any thoughts on what might be causing this?

Advertisement

Answer

A table name can’t be used as a parameter. It must be hard coded. So you can do something like:

JavaScript
Advertisement