sqlite - Naming complex sub-select "as" in case statement -


I am trying to stop the results of a complex sub-selection, which is part of a larger INSERT statement If the tap is being used, the value of the field should be empty string rather than empty space.

Overall, the inserted file looks like this:

  Enter in the record (ID, Field 1, Field 2) value (Val 1, Val 2, & lt; Complex selection & gt;);  

I can use the prevention of a complex selection:

  when & lt; Select complex & gt; Then & lt; Select complex & gt; Otherwise the problem is 'B'  

The problem is, I do not want to repeat the complex selection because the query is twice bigger, it is difficult to read, prone to error If the query has to change a bit, etc., so I would like to name the result of the selection, so I can only mention the value instead. But when I try to do this I get an error:

  select when  

or

  when (& lt; complex select & gt; as one) again There is an error in the form of another 'B'  

:

  with "as": syntax error  

You can provide a column of a complex name, but to get a value out of a subquery, SELECT must be used:

  Enter in the record (ID, Field 1, Fee 2) value (Val 1, Val 2, (when another "Select again ...") to end (select ... as ...));  

(The subkey can be given a name, but it does not matter.)

However, to convert an empty value to an empty string, you can only use it:

  Enter the record (id, field1, field2) value (val1, val2, IFNULL (SELECT ...), ''));  
< / Div>

Comments