pat_authors という 2 つの列を持つテーブルがあります。last_name、first_initials という 2 つの列の異なる組み合わせを選択したいと考えています。次のコマンドは、正しい情報を取得するために機能します。
select distinct last_name, first_initials from pat_authors;
ただし、同じ情報を取得して、unique_authors という名前の別のテーブルに挿入したいと考えています。unique_authors には、authorID、last_name、first_initials の 3 つの列があります。
私は非常に多くのバリエーションのコードを試しましたが、夢中になっています。正しい試みであることに最も近いと私が考えた2つは次のとおりです。
select distinct author_last_name, author_initials into uniqueauthors from pat_authors;
エラーが発生しました-1327:undeclared variable: uniqueauthors
私も試してみました
insert into uniqueauthors select distinct author_last_name, author_initials from pat_authors;
ここで私はError Code: 1136. Column count doesn't match value count at row 1.
大丈夫だと思ったauthorID
NOT NULL AUTO_INCREMENT