答案 0 :(得分:0)
要连接字符串,您可以使用" ||"。例如:
{% extends "site_base.html" %}
{% block more_extra_script %}
{% load inplace_edit %}
{% inplace_css 0 %}
{% inplace_js 1 0 %}
{% endblock more_extra_script %}
{% block content %}
<div class="container-fluid">
<p><a class="btn btn-default" href="{% url 'pricelist_list' %}">PriceList Listing</a></p>
<h2>Pricelist for {{ pricelist_date }}</h2>
<p>Double-click a price to edit it</p>
<table class="table table-responsive table-striped .table-bordered .table_hover">
<thead class="info">
<th>Product</th>
<th>Unit</th>
<th>Price</th>
</thead>
<tbody>
{% for prod in products %}
<tr>
<td>{{prod.product}}</td>
<td>{{prod.unit}}</td>
<td>{% inplace_edit "prod.price" %}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}
答案 1 :(得分:0)
试试这样:
使用NULL
值连接字符串会返回NULL
。 ISNULL()
会设置默认设置NULL
,而NULLIF
会在满填条件下返回NULL
:
DECLARE @mockup TABLE(Column1 VARCHAR(1),Column2 VARCHAR(1));
INSERT INTO @mockup VALUES('1','2'),('-','2'),('1','2'),('-','-'),('2','-'),('1','2');
SELECT ISNULL(NULLIF(Column1 + '|','-|'),'')
+ISNULL(NULLIF(Column2,'-'),'')
FROM @mockup
结果
1|2
2
1|2
2|
1|2