Dropping table using Select result

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jonathan Villa

    Dropping table using Select result

    I have a shopping cart which creates temporary tables in the format of
    zorder_<phpsess ionid>;

    These tables are used to hold a customers order while they shop and
    after checking out, it is dropped. The values of the shopping cart are
    put together in an HTML table and stored as their history.

    What I want to do is to run a cron job to delete the orders which were
    left undone once a day at about midnight. Here is my current query

    SELECT table_name FROM orders WHERE RIGHT(started,8 ) < RIGHT(NOW(),8)
    AND completed < 1 AND LEFT(started,10 ) = LEFT(NOW(),10);

    I was hoping to do something like this:

    DROP TABLE (SELECT table_name FROM orders WHERE RIGHT(started,8 ) <
    RIGHT(NOW(),8) AND completed < 1 AND LEFT(started,10 ) = LEFT(NOW(),10)) ;

    But from my understanding, MySQL does not support nested queries.

    Is there a query-based way to do this...




    --
    MySQL General Mailing List
    For list archives: http://lists.mysql.com/mysql
    To unsubscribe: http://lists.mysql.com/mysql?unsub=m...ie.nctu.edu.tw

Working...