一致するユーザー名に基づいてテーブル内の行の値を更新します
Q: テーブル値を更新します
SQL Database には、table_a と table_b という 2 つのテーブルがあり、どちらにも user_name という共通の列があります。 table_b 内の特定の列 (column_b_1 および column_b_2 という名前) を、一致する user_name 値に基づいて table_a 内の対応する列 (column_a_1 および column_a_2) にコピーしたいと考えています。 SQL ステートメントを使用してこれを実現するにはどうすればよいですか?
答え: 解決策
適切なインデックスが配置されている場合は、次の UPDATE ステートメントを使用できます:
UPDATE table_a SET column_a_1 = (SELECT table_b.column_b_1 FROM table_b WHERE table_b.user_name = table_a.user_name), column_a_2 = (SELECT table_b.column_b_2 FROM table_b WHERE table_b.user_name = table_a.user_name) WHERE EXISTS ( SELECT * FROM table_b WHERE table_b.user_name = table_a.user_name );
注: この UPDATE ステートメントはサブクエリを使用して、一致する user_name を持つ table_a 内の各行に対応する列の値を table_b から取得します。 。
パフォーマンスが懸念される場合は、SELECT および JOIN 操作を使用して、変更された行を保存する一時テーブルを構築することを検討してください。その後、table_a から既存のデータを削除し、一時テーブルから再設定できます。
以上が一致するユーザー名に基づいて SQL テーブルの行を更新するにはどうすればよいですか?の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

todropaviewinmysql、 "dropviewifexistsview_name;" andtomodifyaviewを使用して、 "createorreplaceviewview_nameasselect ..."を使用します

mysqlviewscanefectiveativeativeizedesignpatternslikeadapter、decorator、factory、andobserver.1)adapterpatternadaptsdatafromdifferenttablesintoaunifiedview.2)decoratorpatternenhancesdatawithedfieldsfieldsiffieldsiffieldsiffiedを

viewsinmysqlarebenefentialforsimprifiningcomplexqueries、拡張セキュリティ、ダタコンシーニング、および最適化されたパフォーマンスを保証する1)itsmplifyififycomplexqueriesbyencapsulsingthemintoreusableviews.2)viewsencurationecuritybycontrollingcescesces.3)

to CreateAsimpleviewinmysql、usethecreateviewstatement.1)DefinetheTheTheThecreateview_nameas.2)SpecifyTheSelectStatementtatementtatementtatementtatementtatementtatementedeSireddata.3)

tocleateusersinmysql、usethecreateuserstatement.1)foralocaluser:createUser'localuser '@' localhost'identifidedifiedifiedified 'securepassword';

mysqlviewshavelimitations:1)supportallsqloperations、制限、dataManipulationswithjoinsorubqueries.2)それらは、特にパフォーマンス、特にパルフェクソルラージャターセット

reperusermanmanagementInmysqliscialforenhancingsecurationsinginuring databaseaperation.1)usecreateusertoaddusers、指定connectionsourcewith@'localhost'or@'% '。

mysqldoes notimposeahardlimitontriggers、しかしpracticalfactorsdeTerminetheireffectiveuse:1)serverconufigurationStriggermanagement; 2)complentiggersincreaseSystemload;


ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

Video Face Swap
完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

人気の記事

ホットツール

EditPlus 中国語クラック版
サイズが小さく、構文の強調表示、コード プロンプト機能はサポートされていません

SublimeText3 Mac版
神レベルのコード編集ソフト(SublimeText3)

SublimeText3 英語版
推奨: Win バージョン、コードプロンプトをサポート!

ゼンドスタジオ 13.0.1
強力な PHP 統合開発環境

SublimeText3 中国語版
中国語版、とても使いやすい
