- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有以下两个表:
table1
id
name
ownedby
table2
id
ownername
这里,在table1中,ownedby可以为0(表示它不被任何人拥有)或引用table2的id列。现在我想要的是从 table1 获取数据,但如果owenedby>0
,则从 table2 获取所有者名称输出基本上是:
1 0 ==>owned by no one
2 Barka =======> owned by barka
最佳答案
以下查询应该有效(尽管我没有测试它):
select t1.id, t1.name,
(case when t1.ownedby = 0 then 'No one'
else t2.ownername
end) as Ownername
from table t1
Left Join table t2
on t1.ownedby = t2.id
group by t1.id;
希望对你有帮助!
关于mysql - MySQL根据table1中的值从table2中不相关的表中获取记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46911983/
我有这张图: digraph G { 1 [label="car"]; 2 [label="x"]; 3 [label="car"]; 4 [label="y"]; 5 [label="cdr"];
我有一个大型查询,其中一个简单的子查询优化将其从 8 分钟缩短到 20 秒。我不确定我是否理解为什么优化会产生如此巨大的效果。 本质上,这是问题部分: SELECT (bunch of stuff)
我在 NetBeans IDE 6.9.1 和 GlassFish 3 中遇到非常奇怪的问题。在使用 64 位 JDK 在 Windows 7 上安装 NetBeans 后,在没有创建任何项目的情况下
我有两个长度相同的数组。第一个数组是静态的,具有这种格式的数据 a = [['q', 10], ['s', 20], ['z', 40], ['d', 15]] 和另一个数组 b = [1, 0, 0
我在下面的代码中有一个编译错误。编译器似乎将类方法 set 解释为一个模板,乍一看,它与我的代码完全无关。 #include #include using namespace std; templ
我有一个完整的 Canvas CCLayer,上面有几个小的 CCLayer - 它们是按钮。在按钮上我启用了触摸监听器: - (id)init { if ((self = [super init
关于 this page ,当您将鼠标悬停在右上角的红色标记上时,css3 变换会旋转图像。这按预期工作,但 div.last.half 短暂地向右单击并返回到它的原始位置。 这仅出现在 Chrome
我目前正在重新设计我的网站以包含两栏。左栏是带有一些链接和文本的侧边栏,右栏是页面的正文(不是 )。我遇到的问题是页面上两个完全独立的元素的 CSS 规则会影响这两个元素。 因为这可能没有意义,这是
这是问题 here 的跟进关于使用参数依赖查找 (ADL) 的函数重载。我想检查一下我在这种情况下对规则的理解,所以我写了一些测试代码。 首先,在 std 中当然没有 HasPtr 类的交换,所以我写
我是 Developer Portal 中两个开发团队的成员。一个团队不再存在,也不再由团队的“代理”维护。 现在这就是我的问题。我正在尝试在 Xcode 中刷新我的配置文件,但不断收到一条消息,告诉
在调试问题时,我注意到在改变方向时,viewDidLoad不相关的UIViewController正在被调用。 它似乎与我的问题无关,但这完全很奇怪。 这个UIViewController只能从 UI
今晚,当我拖放一个早上运行良好的项目时,我继续收到数千个这样的错误。我有 140 个类,我无法跟踪我所做的所有修改:(。但我从未更改过与拖/放功能相关的任何内容。我已经完全远离了代码中引发这些问题的行
我的网页布局有一个奇怪的行为。当我在“sideBar”div 中添加更多 div 时,网页的中心部分被下推。它们与中心部分无关。他们有边界,我看到他们离“主要”分区很远。有什么办法可以防止它,或者我每
我们有 3 个独立的 git 存储库(每个都有一些分支),我们想将它们 merge 为一个保留完整历史记录和访问分支的能力,如下所示: 这就是我们所拥有的。 3 个 repo : /A/.git /B
我意识到“为什么会这样”的问题通常不是最好的问题,但是 SO 上有很多人关注标准委员会的讨论,所以我希望可以如实回答,因为我很好奇至于答案是什么。 基本上,当我第一次看到 std::result_of
我已经设法使 SqlDependency 正常工作,但前提是我不在我认为与 SqlDependency 无关的 SQL 事务中使用 IsolationLevel.ReadUncommited。 当我在
我一直在尝试使用反射动态设置字段。当谈到泛型类时,有一个障碍。考虑这段代码: 包装器.java: public class Wrapper { private T var; publi
我是一名优秀的程序员,十分优秀!