MySQL INSERT Using Subquery with COUNT() on the Same Table
I'm having trouble getting an `INSERT` query to execute properly, and I can't seem to find anything on Google or Stack Overflow that solves this particular issue.

I'm trying to create a simple table for featured entries, where the `entry_id` is saved to the table along with it's current order.

My desired output is this:

If the `featured` table currently has these three entries:

    featured_id    entry_id    featured_order
    1              27          0
    2              54          1
    4              23          2

I want the next entry to save with `featured_order`=3.

I'm trying to get the following query to work with no luck:

    INSERT INTO `featured`
    (
        `entry_id`, `featured_order`
    )
    VALUES
    (
        200,
        (SELECT COUNT(*) AS `the_count` FROM `featured`)
    )

The error I'm getting is: `You can't specify target table 'featured' for update in FROM clause`.

Can anyone help with a solution that gets the count without causing an error?

Thanks in advance!
MySQL INSERT Using Subquery with COUNT() on the Same Table
===

I'm having trouble getting an `INSERT` query to execute properly, and I can't seem to find anything on Google or Stack Overflow that solves this particular issue.

I'm trying to create a simple table for featured entries, where the `entry_id` is saved to the table along with it's current order.

My desired output is this:

If the `featured` table currently has these three entries:

    featured_id    entry_id    featured_order
    1              27          0
    2              54          1
    4              23          2

I want the next entry to save with `featured_order`=3.

I'm trying to get the following query to work with no luck:

    INSERT INTO `featured`
    (
        `entry_id`, `featured_order`
    )
    VALUES
    (
        200,
        (SELECT COUNT(*) AS `the_count` FROM `featured`)
    )

The error I'm getting is: `You can't specify target table 'featured' for update in FROM clause`.

Can anyone help with a solution that gets the count without causing an error?

Thanks in advance!