在本文中,我们将给您介绍关于为什么我的T-SQL左联接不起作用?的详细内容,并且为您解答sql左联的相关问题,此外,我们还将为您提供关于c–为什么我的删除节点功能不起作用?、html–为什么我的fav
在本文中,我们将给您介绍关于为什么我的T-SQL左联接不起作用?的详细内容,并且为您解答sql 左联的相关问题,此外,我们还将为您提供关于c – 为什么我的删除节点功能不起作用?、html – 为什么我的favicon链接不起作用?、jquery – 为什么我的.on(‘更改’)不起作用?、php – 为什么我的mysql DISTINCT不起作用?的知识。
本文目录一览:- 为什么我的T-SQL左联接不起作用?(sql 左联)
- c – 为什么我的删除节点功能不起作用?
- html – 为什么我的favicon链接不起作用?
- jquery – 为什么我的.on(‘更改’)不起作用?
- php – 为什么我的mysql DISTINCT不起作用?
为什么我的T-SQL左联接不起作用?(sql 左联)
您可以运行此命令并告诉我为什么结果集只有两行吗?它应该有三个,看起来像这样…
appId stepId section start
101 1 Section 1 2016-01-03 00:00:00.000
101 2 Section 2 2016-01-03 00:00:00.000
101 10 Section 3 NULL
这是sql,因此您可以将其粘贴到查询工具中
create table #appSteps(stepId decimal,section nvarchar(50))
insert into #appSteps (stepId,section) values (1,'Section 1')
insert into #appSteps (stepId,section) values (2,'Section 2')
insert into #appSteps (stepId,section) values (3,null)
insert into #appSteps (stepId,section) values (4,section) values (10,'Section 3')
create table #appProgress(stepId decimal,appId int,start datetime)
insert into #appProgress (stepId,appId,start) values (1,101,'1/3/2016')
insert into #appProgress (stepId,start) values (2,start) values (3,start) values (4,'1/3/2016')
select p.appId,s.stepId,s.section,p.start
from #appSteps s with (nolock)
left join #appProgress p on s.stepId = p.stepId
where s.section is not null
and p.appId = 101
drop table #appSteps
drop table #appProgress
我无法弄清楚为什么#appSteps中的所有3个非空行都没有返回
c – 为什么我的删除节点功能不起作用?
int LinkedList::removeTailRec(Node *n) { // check for the base case(s) if(n->next == NULL) { Node *tmp = new Node(); tmp = n; int val = n->value; tmp = NULL; return val; } else return removeTailRec(n->next); // else call the recursive method }
解决方法
然后,在您的代码上.你实际上没有从列表中删除任何内容.
if(n->next == NULL) { Node *tmp = new Node(); ^^^^^^^^^^ //Useless,and dangerous. This memory is never free'd tmp = n; int val = n->value; tmp = NULL; ^^^^^^^^^^ //You just set a local variable to NULL,you're not deleting anything return val; }
如果要删除节点,则必须保留对前一节点的引用(例如,具有双向链表,即具有指向下一个元素的指针和指向每个节点中前一个元素的指针,或者直接在上一个节点上工作).
将此前一个节点设置为nullptr旁边,存储节点的值,然后删除节点指针.
一种方法是使用指向下一个节点的指针:
int LinkedList::removeTailRec(Node *n) { //EDIT: Adding a check for n validity if(!n){ //Here,you should have a way of detecting //a call to your method with a null pointer return 0; } Node* nextNode = n->next; // check for the base case(s) if(nextNode->next == nullptr) { //Get the next node value int val = nextNode->value; //Set the current node next member to nullptr n->next = nullptr; //Free the last node delete nextNode; return val; } else{ return removeTailRec(n->next); } // else call the recursive method }
html – 为什么我的favicon链接不起作用?
我的favicon.ico文件与我的HTML文件位于同一目录中,但出于某种原因,当我将其上传到我的Web服务器时它不会出现.我清除了缓存,关闭了我的浏览器,然后重新打开它,但仍然没有显示图标.
如果有人能解释为什么会这样,我会非常感激.
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
编辑:此外我不知道这是否会影响它,但我的网络服务器上有一个默认的图标.我不知道是否有可能覆盖这个.
编辑2:不确定这是否有所作为,但这是我头脑的基本结构.
<head> <Meta charset="utf-8"> <Meta name="author" content=""> <Meta name="description" content="Home"> <link rel="icon" type="image/x-icon" href="/favicon.ico"> <title></title> <link href="css/style.css" rel="stylesheet" type="text/css" media="all" /> </head>
解决方法
此外,如果您的favicon.ico位于服务器的根目录http://example.com/favicon.ico,并且您的页面位于子目录http://example.com/blog/中,则浏览器将尝试搜索favicon当前目录http://example.com/blog/favicon.ico中的.ico,这将导致404错误;为了避免这种情况,你应该设置href =“/ favicon.ico”,这样它总是指向根目录,无论你在哪个子目录中.
jquery – 为什么我的.on(‘更改’)不起作用?
我正在尝试将更改事件附加到type =“file”输入,但它只是不起作用.
我试过两种方法,第一种:
$('.container').on('change','.file-input-hidden',function(){
其中输入有一个文件输入隐藏类.
第二个:
$('.container').on('change','input[type="file"]',function(){
但是当使用输入选择/更改文件时,既不会激活该功能.
出了什么问题?
编辑:
在这里查看页面:LINK
和js:
$('.container').on('click','.file-browse',function(){ var thisone = $(this).attr('id'); $('input[name="input-'+ thisone+'"]').click(); }); $('.file-input-hidden').on('change',function(){ var thetext = $(this).val(); var thetextsplit = thetext.split('\\').pop(); var thisone = $(this).attr('name').split('-').pop(); if($('.file-info').text() == thetextsplit){ alert('you have already selected this file'); $(this).replaceWith( $(this).val('').clone( true ) ); } else{ $('#info-'+ thisone).text(thetextsplit); $('#clear-'+ thisone).fadeIn(100); var emptyinputs = $('.file-info:empty').length; if(emptyinputs <1){ var filledinputs = $(".file-info:contains('.')").length; var thisnumber = filledinputs + 1; var filecontainer = $('<div>').addClass('file-container'); var fileinfo = $('<div>').addClass('file-info').attr('id','info-file'+thisnumber); var filebrowse = $('<div>').addClass('file-browse').attr('id','file'+thisnumber).text('browse'); var fileclear = $('<div>').addClass('file-clear').attr('id','clear-file'+thisnumber).text('X'); var newinput = $('<input>').attr({'type':'file','name':'input-file'+thisnumber}).addClass('file-input-hidden'); var thebody = $('.container'); (filecontainer).append(fileinfo,filebrowse,fileclear); filecontainer.appendTo(thebody); var theform = $('#hidden-inputs'); newinput.appendTo(theform); } } if($(this).val() == ''){ $('#clear-'+thisone).fadeOut(100); } }); $('.container').on('click','.file-clear',function(){ var thisone = $(this).attr('id').split('-').pop(); $('input[name="input'+ thisone +'"]').replaceWith( $('input[name="input'+ thisone +'"]').val('').clone( true ) ); $('#info-'+ thisone).text(''); $(this).fadeOut(100); });
HTML:
<div> <div> <divid="info-file1"></div> <divhttps://www.jb51.cc/tag/bro/" target="_blank">browse" id="file1">browse</div> <divid="clear-file1">X</div> </div> </div> <form action="" method="POST" enctype="multipart/form-data" id="hidden-inputs"> <input type="submit"/> <input type='file' name="input-file1"/> </form>
解决方法
jQuery的:
$('.container').on('change',function(){
HTML:
<div>...</div> <form> <input type='file' name="input-file1"/> </form>
它不起作用,因为输入[type =“file”]不在.container中.
把它放在div.container里面或试试这样的东西..
$(document).on('change',function(){
See the documentation for .on()
.
php – 为什么我的mysql DISTINCT不起作用?
为什么下面的两个查询返回重复的member_id而不是第三个?
我需要第二个查询才能使用distinct.无论何时我运行GROUP BY,此查询都非常慢,并且结果集不会返回与distinct相同的值(值是错误的).
SELECT member_id, id
FROM ( SELECT * FROM table1 ORDER BY created_at desc ) as u
LIMIT 5
+-----------+--------+
| member_id | id |
+-----------+--------+
| 11333 | 313095 |
| 141831 | 313094 |
| 141831 | 313093 |
| 12013 | 313092 |
| 60821 | 313091 |
+-----------+--------+
SELECT distinct member_id, id
FROM ( SELECT * FROM table1 ORDER BY created_at desc ) as u
LIMIT 5
+-----------+--------+
| member_id | id |
+-----------+--------+
| 11333 | 313095 |
| 141831 | 313094 |
| 141831 | 313093 |
| 12013 | 313092 |
| 60821 | 313091 |
+-----------+--------+
SELECT distinct member_id
FROM ( SELECT * FROM table1 ORDER BY created_at desc ) as u
LIMIT 5
+-----------+
| member_id |
+-----------+
| 11333 |
| 141831 |
| 12013 |
| 60821 |
| 64980 |
+-----------+
我的表样本
CREATE TABLE `table1` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`member_id` int(11) NOT NULL,
`s_type_id` int(11) NOT NULL,
`created_at` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `s_FI_1` (`member_id`),
KEY `s_FI_2` (`s_type_id`)
) ENGINE=InnoDB AUTO_INCREMENT=313096 DEFAULT CHARSET=utf8;
解决方法:
disTINCT是一个关键字,只能应用于整个SELECT,而不能应用于单个字段.它确保数据库不返回两个相同的行.这就是为什么你的第二个查询与disTINCT只返回一次每个member_id,而你的第一个返回它两次.在其结果集中,每行确实是唯一的,即使您可以获得相同member_id的几倍.
今天关于为什么我的T-SQL左联接不起作用?和sql 左联的分享就到这里,希望大家有所收获,若想了解更多关于c – 为什么我的删除节点功能不起作用?、html – 为什么我的favicon链接不起作用?、jquery – 为什么我的.on(‘更改’)不起作用?、php – 为什么我的mysql DISTINCT不起作用?等相关知识,可以在本站进行查询。
本文标签: