0

I want to create a VIEW, which contains parameters submitted by user (POST). I use mysqli prepared statemets to make it secure.

The query fails with an error:

Error 1351: View's SELECT contains a variable or parameter.

The query is: CREATE VIEW emailletters_view_11 AS SELECT * FROM clients WHERE c_title LIKE CONCAT('%', ?, '%')

I need to create views using parameters from users because these views are actually filters that users create on where web page. I don't want to store filter parameters and compose sql query each time the filter is used. I want to store each filter as separate view in by database.

What would you recommend?

Georgy Nemtsov
  • 786
  • 1
  • 8
  • 19
  • It doesn't work that way. Only you need something must not mean that there is something. Also if I may ask: Which part of the error message is not clear to? I think it pretty much says what the case is, doesn't it? – hakre Apr 03 '15 at 10:29
  • Well, I understood the error completely. My question is "what would you recommend to solve such task". I tried to rephrase my question.. – Georgy Nemtsov Apr 03 '15 at 10:43
  • Well as that is an error which forbids to make use of parameters in a view, the error is already a clear recommendation to not use parameters in a view. Isn't that obvious? You could take a look into the duplicate, that's still my previous recommendation otherwise I wouldn't have closed it against. – hakre Apr 03 '15 at 10:50

0 Answers0