在本文中,我们将详细介绍一行中的SQL输出的各个方面,并为您提供关于sql输出第一行的相关解答,同时,我们也将为您带来关于bash–如何将一行中的行附加到另一个文件的每一行的末尾?、c#–为什么在一行
在本文中,我们将详细介绍一行中的 SQL 输出的各个方面,并为您提供关于sql输出第一行的相关解答,同时,我们也将为您带来关于bash – 如何将一行中的行附加到另一个文件的每一行的末尾?、c# – 为什么在一行中声明一个变量,并在下一行中分配它?、html输入框在一行中,但第二个文本框不在同一行中、mysql过程在更新前一行中的数字引用时进行更新的有用知识。
本文目录一览:- 一行中的 SQL 输出(sql输出第一行)
- bash – 如何将一行中的行附加到另一个文件的每一行的末尾?
- c# – 为什么在一行中声明一个变量,并在下一行中分配它?
- html输入框在一行中,但第二个文本框不在同一行中
- mysql过程在更新前一行中的数字引用时进行更新
一行中的 SQL 输出(sql输出第一行)
如何解决一行中的 SQL 输出?
例如,我“从 id = 2 的帖子中选择 *”
它将输出 1 行中的所有“id 2”信息
规范化后,多对多关系有了新表。
但我想知道如何输出标准化之前的结果?
或者我需要修改后端代码中的输出?
谢谢
解决方法
一种方法是group_concat()
,它将所有值放在一行中:
select p.*,group_concat(t.name) as tags
from posts p join
tag_post tp
on tp.post_id = p.id join
tag t
on tp.tag_id = t.id
group by p.id;
注意:这里假设 posts(id)
被声明为主键(或至少是 unique
),因此您可以将 select p.*
与 group by
一起使用。
bash – 如何将一行中的行附加到另一个文件的每一行的末尾?
cat dog baboon @H_301_10@feline canine primate @H_301_10@我想在添加空格后将一个文件中的行附加到另一个文件的末尾.我知道在bash中使用for循环来做到这一点的方法,但我认为有一个命令可以做这种事情,我只是记不住了.
输出应如下所示:
cat feline dog canine baboon primate @H_301_10@
解决方法
paste --delimiter=' ' file1 file2@H_301_10@注意:结果将写入stdout.如果要将结果存储在文件中,请使用重定向运算符:
paste --delimiter=' ' file1 file2 > outputfile@H_301_10@有关该命令的更多信息,请运行man paste.
c# – 为什么在一行中声明一个变量,并在下一行中分配它?
some_type val; val = something;
喜欢
DataTable dt; dt = some_function_returning_datatable();
要么
DataTable dt = new DataTable(); dt = some_function_returning_datatable();
代替
some_type val = something; DataTable dt = some_function_returning_datatable();
我最初认为这是一个习惯,当你必须在范围顶部声明所有局部变量时.但我已经学会了不要那么快地解雇资深开发者的习惯.
(在我的第3段代码中,当我们首先使用new然后从函数分配dt时,它不会浪费内存)
那么,有一个很好的理由在一行中声明,然后分配吗?
解决方法
In my 3rd code section will it not be wastage of memory when we assign dt first with new and then from function
是的,确实如此.只是相对较小 – 创建一个无用的DataTable对象 – 但仍然浪费和不清楚.
So,is there a good reason for declaring in one line,and assigning afterwards?
仅当您没有立即获得该值时.例如:
string x; if (someCondition) { // Do some work x = someResult; } else { // Do some other work x = someOtherResult; }
通常可以使用条件运算符或将该代码提取到方法中来改进.虽然有时它不会那么成功.
对于简单的情况:
Foo x = SomeInitializationWithNoUsefulSideEffects(); x = SomeUsefulValue();
要么
Foo x; x = SomeUsefulValue();
你绝对应该重构
Foo x = SomeUsefulValue();
声明点确实有所作为的另一个有趣情况是捕获的变量,尽管通常不是它的预期方式:
int x; for (int i = 0; i < 10; i++) { x = SomeFunction(); actions.Add(() => Console.WriteLine(x)); }
VS
for (int i = 0; i < 10; i++) { int x = SomeFunction(); actions.Add(() => Console.WriteLine(x)); }
在第一个片段中,每个委托将捕获相同的变量,因此它们都可以有效地看到SomeFunction返回的最后一个值.在第二个片段中,每个代表将捕获x的单独“实例”.
html输入框在一行中,但第二个文本框不在同一行中
如何解决html输入框在一行中,但第二个文本框不在同一行中?
这是我用 ASP.Net 网页编写的代码,我在一行中添加了三个 html 文本框,但第三个文本框不在同一行或同一行中。
<div>
<div>
<div>
<input type="text" runat="server" id="NameTextBox"placeholder="Merchant Description" aria-label="Description" maxlength="25" tabindex="6" />
</div>
<asp:HiddenField runat="server" ID="NameHdn" ClientIDMode="Static" />
</div>
<div>
<div>
<input type="text" runat="server" id="TransactionAmountTextBox"placeholder="From " aria-label="From Transaction Amount" data-allownegative="true"maxlength="14" tabindex="7" onkeyup="sync()"/>
<%-- <input type="text" runat="server" id="AmountTextBox" maxlength="14" tabindex="13"/>
<input type="text" runat="server" id="Text1" maxlength="14" tabindex="13" onkeyup="sync()"/> --%>
</div>
<asp:HiddenField runat="server" ID="AmountHdn" ClientIDMode="Static" />
</div>
<%--Added Comaprison Dollar Search --%>
<div>
<div>
<%--<input type="text" runat="server" id="AmountTextBox_2" maxlength="14" tabindex="13" /> --%>
<%--<input type="text" runat="server" id="Text2" maxlength="14" tabindex="13" onkeyup="sync()"/>--%>
<input type="text" runat="server" id="AmountTextBox_2"placeholder="To " aria-label="To Transaction Amount" data-allownegative="true"maxlength="14" tabindex="13" />
</div>
<asp:HiddenField runat="server" ID="ToAmountHdn" ClientIDMode="Static" />
</div>
</div>
解决方法
这是由于您为列提供了额外的边距。列的远程样式标记边距。
开关
.scss
到
mysql过程在更新前一行中的数字引用时进行更新
有一张这样的桌子
______________________
| id | 标题| 订购|
| ---------------------- |
| 1 | test1 | 1 |
| ----- | -------- | ------- |
| 2 | test2 | 2 |
| ----- | -------- | ------- |
| 3 | test3 | 3 |
| ----- | -------- | ------- |
| 4 | test4 | 4 |
'----------------------'
当我在mysql shell中引入对行的单个更新时
$ sql> UPDATE`table` SET order = 1 WHERE id = 3;
然后过程或方法在更新较低的值之前重新采样顺序列中的订单列,以使其顺序更新
______________________
| id | 标题| 订购|
| ---------------------- |
| 1 | test1 | 2 |
| ----- | -------- | ------- |
| 2 | test2 | 3 |
| ----- | -------- | ------- |
| 3 | test3 | 1 |
| ----- | -------- | ------- |
| 4 | test4 | 4 |
'----------------------'
任何帮助,将不胜感激,谢谢!
我们今天的关于一行中的 SQL 输出和sql输出第一行的分享已经告一段落,感谢您的关注,如果您想了解更多关于bash – 如何将一行中的行附加到另一个文件的每一行的末尾?、c# – 为什么在一行中声明一个变量,并在下一行中分配它?、html输入框在一行中,但第二个文本框不在同一行中、mysql过程在更新前一行中的数字引用时进行更新的相关信息,请在本站查询。
本文标签: