以下のクエリを実行してmysqlにテーブルを作成しようとすると、エラーが発生します。
create table newtable (
version_id int(11) auto_increment not null,
test_id int(11) default version_id,
primary key(version_id)
);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'version_id not null, primary key(version_id), unique key(test_id) )' at line 1
上記のエラーが発生しています。
それ以外の場合は機能するため、問題はtest_idのデフォルトをversion_idとして設定することだと思います。
ありがとう
バラ
-- Update
これが私がやりたかったことです、
新しい行を作成するときに、version_idをキーとして使用したいと思います。更新するときは、既存のレコードの値をキーとして使いたいです。test_idは主キーではないことに注意してください。