Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to put a literal "?" in a Mysql query with bind variables
    primarykey
    data
    text
    <p>I have the following query:</p> <pre><code>select subclasses.id,participants_subclasses.participant_id from subclasses left outer join participants_subclasses on participants_subclasses.participant_id = ? and subclasses.id = participants_subclasses.subclass_id where subclasses.classification_id = ? and subclasses.showhover order by subclasses.seq, IF(LEFT(subclasses.code, 1) = '&lt;', Extractvalue(subclasses.code, "//texts/text/content"), subclasses.code) </code></pre> <p>The above query is processing a table where the code column sometimes has text and sometimes has XML with text inside a tag. The above query works. The side-effect is that a code value cannot start with a "&lt;" which should be acceptable, but the order by would mistake it for XML content. The query below would be more specific and accurate:</p> <pre><code>select subclasses.id,participants_subclasses.participant_id from subclasses left outer join participants_subclasses on participants_subclasses.participant_id = ? and subclasses.id = participants_subclasses.subclass_id where subclasses.classification_id = ? and subclasses.showhover order by subclasses.seq, IF(LEFT(subclasses.code, 5) = '&lt;?xml', Extractvalue(subclasses.code, "//texts/text/content"), subclasses.code) </code></pre> <p>However this variation checking the XML header in the content fails with a "NameInput Array does not match ?" error in MySQL. It appears that the ? inside <code>&lt;?xml</code> literal is being mistaken for a bind target. And I am passing 2 values to be bound - which again is correct. </p> <p>So my question is - how do I get the <code>&lt;?xml</code> literal to not be mistaken for a bind value target???</p>
    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.
    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