Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
PHPでcronタスク、「id」= 20のときに行をランダムに選択し、行を別のテーブルに転送してから古いテーブルを切り捨てる方法
このタイプのコードの書き方について誰か教えてもらえますか?
これは mysql です。id は phpmysql auto_increment によって設定されます。
id1行しか選択していないため、行をランダムにauto_increment選択できませんでした。デフォルトでは、mysql の PHP 拡張機能は複数のステートメントを受け入れません。したがって、あなたが正しいことを理解すると、2つのSQLステートメントで実行されます
id
auto_increment
INSERT INTO <table2> (<cols>) SELECT <cols> FROM <table1> WHERE id=20 TRUNCATE TABLE <table2>