Note that there are some explanatory texts on larger screens.

plurals
  1. POCheck if `LIKE` patterns intersects in Postgres
    primarykey
    data
    text
    <p>There ara two strings in some request that are patterns that used within <code>LIKE</code> expressions (with <code>_</code> and <code>%</code> placeholders). I want to find if this patterns intersects (have some string that matches them both). Is there any way to do that?...</p> <hr> <p>“Like pattern” corresponds to finit or infinit set of strings. Each string in this set matches to given pattern. I want to check if intersection of string sets for two given patterns is not empty. Thus it is better to say patterns conjunction. In a math language:</p> <blockquote> <p><em>S</em> — set of strings<br> <em>P</em> — set of patterns (where each pattern has one or more string representation)</p> <p><em>Sᵢ</em> — subset of strings (<em>Sᵢ ⊂ S</em>) that match pᵢ pattern (where instead of i could be any index). In equation form: “<em>Sᵢ = {s | s ∈ S, s matches pᵢ, pᵢ ∈ P}</em>” — that meas: “<em>Sᵢ</em> is a set of elements that are strings and match <em>pᵢ</em> pattern”. Or another notation: “<em>Sᵢ ⊂ S, ∀pᵢ ∈ P ∀s ∈ S (s matches pᵢ ≡ s ∈ Sᵢ)</em>” — that meas: “<em>Sᵢ</em> is subset of strings and any string is element of <em>Sᵢ</em> if it matches <em>pᵢ</em> pattern”.</p> <p>Let's define conjunction of patterns: “<em>p₁ ∧ p₂ = p₃ ≡ S₁ ∩ S₂ = S₃</em>” — that means: “Set of strings that match conjunction of patterns <em>p₁</em> and <em>p₂</em> is intersection of sets of strings that match <em>p₁</em> pattern and that match <em>p₂</em> pattern”.</p> </blockquote> <hr> <p>For example:</p> <ul> <li><code>ab_d</code> and <code>%cd</code> — intersects</li> <li><code>k%n</code> and <code>kl___</code> — intersects</li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload