{"id":155,"date":"2013-11-12T14:56:53","date_gmt":"2013-11-12T12:56:53","guid":{"rendered":"http:\/\/blog.bellanca-web.com\/?p=155"},"modified":"2016-04-18T09:21:24","modified_gmt":"2016-04-18T08:21:24","slug":"recherche-avec-un-like","status":"publish","type":"post","link":"https:\/\/blog.bellanca-web.com\/?p=155","title":{"rendered":"Recherche avec un LIKE"},"content":{"rendered":"<p>Voici une recherche \u00ab\u00a0standard\u00a0\u00bb avec un LIKE :<\/p>\n<pre class=\"lang:default decode:true \">SELECT * FROM table WHERE champ LIKE 'te_t%';<\/pre>\n<p>Cela retournera par exemple des lignes contenant <strong>texte<\/strong> et <strong>tester<\/strong><\/p>\n<p><em>% : n&rsquo;importe quelles caract\u00e8res (de 1 \u00e0 n)<\/em><\/p>\n<p><em>_ : n&rsquo;importe quel caract\u00e8re (un seul caract\u00e8re)<\/em><\/p>\n<p>&nbsp;<\/p>\n<p>Si l&rsquo;on souhaite vraiment rechercher une cha\u00eene de caract\u00e8re contenant \u00ab\u00a0_\u00a0\u00bb, la solution est d&rsquo;utiliser la clause ESCAPE de la mani\u00e8re suivante :<\/p>\n<pre class=\"lang:default decode:true \">SELECT * FROM table WHERE champ LIKE 'te\\_t%' ESCAPE '\\';<\/pre>\n<p>Le caract\u00e8re \u00ab\u00a0<strong>\\<\/strong>\u00a0\u00bb\u00a0est alors identifi\u00e9 comme un caract\u00e8re d&rsquo;\u00e9chappement (le caract\u00e8re inconnu). Oracle va donc interpr\u00e9ter le \u00ab\u00a0<strong>_<\/strong>\u00a0\u00bb comme devant exister dans la cha\u00eene de caract\u00e8res.<\/p>\n<p>Cela retournera par exemple des lignes contenant <strong>tet_tt<\/strong> et <strong>te&amp;_ts<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Voici une recherche \u00ab\u00a0standard\u00a0\u00bb avec un LIKE : SELECT * FROM table WHERE champ LIKE &lsquo;te_t%&rsquo;; Cela retournera par exemple des lignes contenant texte et tester % : n&rsquo;importe quelles caract\u00e8res (de 1 \u00e0 n) _ : n&rsquo;importe quel caract\u00e8re (un seul caract\u00e8re) &nbsp; Si l&rsquo;on souhaite vraiment rechercher une cha\u00eene de caract\u00e8re contenant \u00ab\u00a0_\u00a0\u00bb, &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.bellanca-web.com\/?p=155\" class=\"more-link\">Continuer la lecture<span class=\"screen-reader-text\"> de &laquo;&nbsp;Recherche avec un LIKE&nbsp;&raquo;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,10],"tags":[],"class_list":["post-155","post","type-post","status-publish","format-standard","hentry","category-base_de_donnees","category-oracle"],"_links":{"self":[{"href":"https:\/\/blog.bellanca-web.com\/index.php?rest_route=\/wp\/v2\/posts\/155","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.bellanca-web.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.bellanca-web.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.bellanca-web.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.bellanca-web.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=155"}],"version-history":[{"count":6,"href":"https:\/\/blog.bellanca-web.com\/index.php?rest_route=\/wp\/v2\/posts\/155\/revisions"}],"predecessor-version":[{"id":240,"href":"https:\/\/blog.bellanca-web.com\/index.php?rest_route=\/wp\/v2\/posts\/155\/revisions\/240"}],"wp:attachment":[{"href":"https:\/\/blog.bellanca-web.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=155"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.bellanca-web.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=155"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.bellanca-web.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=155"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}