I'm having trouble getting a request INSERTto execute correctly, and I can't find anything on Google or Stack Overflow that solves this problem.
I am trying to create a simple table for recognized records, where it is entry_idstored in the table along with the current order.
My desired result:
If the table featuredcurrently has three entries:
featured_id entry_id featured_order
1 27 0
2 54 1
4 23 2
I want the next record to be saved with featured_order= 3.
I am trying to get the following request to work with no luck:
INSERT INTO `featured`
(
`entry_id`, `featured_order`
)
VALUES
(
200,
(SELECT COUNT(*) AS `the_count` FROM `featured`)
)
The error that I get: You can't specify target table 'featured' for update in FROM clause.
Can someone help with a solution that gets the bill without causing an error?
Thanks in advance!