{"id":357,"date":"2025-10-11T09:12:25","date_gmt":"2025-10-11T09:12:25","guid":{"rendered":"https:\/\/fhix.fr\/?p=357"},"modified":"2026-01-08T13:19:21","modified_gmt":"2026-01-08T13:19:21","slug":"comparer-2-tables-en-utilisant-except","status":"publish","type":"post","link":"https:\/\/fhix.fr\/index.php\/2025\/10\/11\/comparer-2-tables-en-utilisant-except\/","title":{"rendered":"Comparer 2 tables en utilisant EXCEPT"},"content":{"rendered":"\n<p>EXCEPT en SQL permet d&rsquo;extraire les diff\u00e9rences entre 2 tables.<br><br>Exemple :  2 tables article avec des contenus diff\u00e9rents<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"346\" height=\"163\" src=\"https:\/\/fhix.fr\/wp-content\/uploads\/2025\/10\/image.png\" alt=\"\" class=\"wp-image-358\" srcset=\"https:\/\/fhix.fr\/wp-content\/uploads\/2025\/10\/image.png 346w, https:\/\/fhix.fr\/wp-content\/uploads\/2025\/10\/image-300x141.png 300w\" sizes=\"auto, (max-width: 346px) 100vw, 346px\" \/><\/figure>\n\n\n\n<p><br>1) Extraire les lignes de ARTICLE qui ne sont pas dans ARTICLE2 :<br><code><strong>SELECT<\/strong> * <strong>FROM<\/strong> article<br><strong>EXCEPT<\/strong><br><strong>SELECT<\/strong> * <strong>FROM<\/strong> article2<\/code><br><mark style=\"background-color:var(--base-3)\" class=\"has-inline-color\">R\u00e9sultat :<\/mark><mark style=\"background-color:var(--base-3)\" class=\"has-inline-color has-accent-color\"><strong> Casquette jaune<\/strong><\/mark><\/p>\n\n\n\n<p>2) Extraire les lignes de ARTICLE2 qui ne sont pas dans ARTICLE :<br><code><strong>SELECT<\/strong> * <strong>FROM<\/strong> article2<br><strong>EXCEPT<\/strong><br><strong>SELECT<\/strong> * <strong>FROM<\/strong> article<\/code><br><mark style=\"background-color:var(--base-3)\" class=\"has-inline-color\">R\u00e9sultat :<\/mark><mark style=\"background-color:var(--base-3)\" class=\"has-inline-color has-accent-color\"> <strong>Beret noir<\/strong><\/mark><\/p>\n\n\n\n<p>3) Il est possible de comparer sur une ou plusieurs colonnes choisies.<br>Par exemple, extraire les couleurs de ARTICLE2 qui ne sont pas dans ARTICLE :<br><code><strong>SELECT<\/strong> couleur <strong>FROM<\/strong> article2<br><strong>EXCEPT<\/strong><br><strong>SELECT<\/strong> couleur <strong>FROM<\/strong> article<\/code><br><mark style=\"background-color:var(--base-3)\" class=\"has-inline-color\">R\u00e9sultat :<\/mark><mark style=\"background-color:var(--base-3)\" class=\"has-inline-color has-accent-color\"> <strong>noir<\/strong><\/mark><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>A noter, il est possible de comparer 2 fichiers source avec EXCEPT :<br>1- OVRDBF FILE(SOURCE1) TOFILE(BIB1\/QRPGSRC) MBR(PGM1)<br>2- OVRDBF FILE(SOURCE2) TOFILE(BIB2\/QRPGSRC) MBR(PGM2)<br>3- <strong>SELECT * FROM<\/strong> source1 <strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">EXCEPT<\/mark><\/strong> <strong>SELECT * FROM<\/strong> source2<\/p>\n\n\n\n<p><br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>EXCEPT en SQL permet d&rsquo;extraire les diff\u00e9rences entre 2 tables. Exemple : 2 tables article avec des contenus diff\u00e9rents 1) Extraire les lignes de ARTICLE qui ne sont pas dans ARTICLE2 :SELECT * FROM articleEXCEPTSELECT * FROM article2R\u00e9sultat : Casquette jaune 2) Extraire les lignes de ARTICLE2 qui ne sont pas dans ARTICLE :SELECT * &#8230; <a title=\"Comparer 2 tables en utilisant EXCEPT\" class=\"read-more\" href=\"https:\/\/fhix.fr\/index.php\/2025\/10\/11\/comparer-2-tables-en-utilisant-except\/\" aria-label=\"En savoir plus sur Comparer 2 tables en utilisant EXCEPT\">Lire la suite<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-357","post","type-post","status-publish","format-standard","hentry","category-sql-db2"],"_links":{"self":[{"href":"https:\/\/fhix.fr\/index.php\/wp-json\/wp\/v2\/posts\/357","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fhix.fr\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fhix.fr\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fhix.fr\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fhix.fr\/index.php\/wp-json\/wp\/v2\/comments?post=357"}],"version-history":[{"count":5,"href":"https:\/\/fhix.fr\/index.php\/wp-json\/wp\/v2\/posts\/357\/revisions"}],"predecessor-version":[{"id":419,"href":"https:\/\/fhix.fr\/index.php\/wp-json\/wp\/v2\/posts\/357\/revisions\/419"}],"wp:attachment":[{"href":"https:\/\/fhix.fr\/index.php\/wp-json\/wp\/v2\/media?parent=357"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fhix.fr\/index.php\/wp-json\/wp\/v2\/categories?post=357"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fhix.fr\/index.php\/wp-json\/wp\/v2\/tags?post=357"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}