在sql server 2008中,我有以下查询:
select
c.title as categorytitle,
s.title as subcategorytitle,
i.title as itemtitle
from categories c
join subcategories s on c.categoryid = s.categoryid
left join itemcategories ic on s.subcategoryid = ic.subcategoryid
left join items i on ic.itemid = i.itemid and i.siteid = 132
where (ic.isactive = 1 or ic.isactive is null)
order by c.title, s.title
Run Code Online (Sandbox Code Playgroud)
我试图在他们的子类别中获取项目,但如果类别或子类别中没有项目,我仍然想要返回记录.永远不会返回没有项目的子类别.我究竟做错了什么?
谢谢
编辑
使用第二个左连接和where子句修改查询,但它仍然没有返回空值.:/
编辑2
将siteid移动到项目左连接.当我这样做时,我获得了比预期更多的记录.有些项目具有空的siteid,我只想在具有特定ID时包含它们.
编辑3
表结构:
Categories Table
-------
CategoryID
Title
SubCategories Table
-------
SubCategoryID
CategoryID
Title
ItemCategories Table
-------
ItemCategoryID
ItemID
SubCategoryID …Run Code Online (Sandbox Code Playgroud) 我有两个页面,在事件发生后的第一页上我使用以下命令更改页面的位置:
window.location.href = "/pageb";
Run Code Online (Sandbox Code Playgroud)
在第二页上,我有一个文档就绪事件,从上面的页面来时不会触发.当页面正常浏览时,就绪事件有效.
$(document).ready(function() {
alert('ready');
});
Run Code Online (Sandbox Code Playgroud)
我正在使用谷歌ajax cdn在我的网页上包含jquery.我很难过......
var colors = new Color[] {
Color.Blue,
Color.Green,
Color.Yellow,
Color.Orange,
Color.Red
};
var min = 0;
var max = 400;
Run Code Online (Sandbox Code Playgroud)
我试图根据另一个数字得到这些值之间的颜色.因此,例如,如果我想要值350的颜色,它将是50%橙色和50%红色.
编辑 - 为清晰起见重新编辑
我能想到的唯一方法是在photoshop中创建渐变图像,然后计算偏移量并抓取像素RGB值.然而,这似乎非常hacky,我想通过某种计算来做到这一点.
有任何想法吗?
我正在编写一个针对appendFormat:内部使用的NSMutableString的类别.
@interface NSMutableString (Additions)
- (void)appendFormatWithLine:(NSString *)format, ...;
@end
@implementation NSMutableString (Additions)
- (void)appendFormatWithLine:(NSString *)format, ... {
va_list args;
va_start(args, format);
// **calling [self appendFormat] gives a 'EXC_BAD_ACCESS'**
[self appendFormat:format, args];
[self appendString:@"\r\n"];
va_end(args);
}
@end
Run Code Online (Sandbox Code Playgroud)
我不知道如何使用va_list或va_start来调用NSMutableString:appendFormat.如何才能做到这一点?