什么是对此的正确查询。(What's the proper query for this. (needs orderby, make some of the values be last and more) MYSQL)
表:用户,学生,组
用户:
行:Username
值:Teacher2
,Teacher3
,Teacher4
,Teacher4
学生们:
行:grpID
,Name
值:(1,John),(1,Joe),(1,Rose),(2,Gina),(2,Mark),(2,Jack),(3,Ted),(4,Fred)团体:
行:grpID
,Handler
值(1,教师1),(2,教师2),(3,教师3),(4,教师4)我想在有人登录时查询(让我们说老师1)
Select `Name` from Students where (I don't know the proper condition here) Order by `Name`
但这是我想要的结果:
Fred Gina Jack Mark Ted Joe John Rose
我希望由Teacher1处理的这3名学生(作为登录的示例用户)是要在查询结果上显示的最后一条记录。
Table: Users, Students, Groups
Users:
Rows:Username
Values:Teacher1
,Teacher2
,Teacher3
,Teacher4
Students:
Rows:grpID
,Name
Values: (1, John), (1, Joe), (1, Rose), (2, Gina), (2, Mark), (2, Jack), (3, Ted), (4, Fred)Groups:
Rows:grpID
,Handler
Values (1, Teacher1), (2, Teacher2), (3, Teacher3), (4, Teacher4)I want to query that when someone is logged in (let's say Teacher1)
Select `Name` from Students where (I don't know the proper condition here) Order by `Name`
but here's the result that I want:
Fred Gina Jack Mark Ted Joe John Rose
I want those 3 students handled by Teacher1 (as example user who logged in) to be the last record to be shown on the result of the query.
原文:https://stackoverflow.com/questions/34840774
满意答案
你的问题很奇怪。 总之,调试器显示你的字典正确,但是
objectForKey
返回nil
。我在最后一个小时想到了这一点,我很确定我只知道这种情况发生的可能性 - 不正确的
hash
或isEqual:
方法。特别是,我认为
isEqual:
方法是不对称的。 换句话说,如果我们有id k = [GAClause parse:@"(x 1 1)"];
然后
[k isEqual:k]
不一定是真的。
然后,如果你得到你的字典键并试图找到它们的值(这与
[NSDictionary description]
相同),则找不到这些值。我相信你应该把你的断点/
NSLog
放入isEqual
并观察比较值时发生了什么。另请注意,字典键已被复制,因此在复制过程中可能会出现相等问题。
Your problem is very strange. In summary, debugger shows your dictionary as correct but
objectForKey
returnsnil
.I was thinking about this for the last hour and I am pretty sure I know only about one possibility how this can happen - incorrect
hash
orisEqual:
methods.Especially, I think that the
isEqual:
method is not symmetric. In other words, if we haveid k = [GAClause parse:@"(x 1 1)"];
then
[k isEqual:k]
doesn't have to be true.
Then, if you get your dictionary keys and try to find their values (which is the same
[NSDictionary description]
does), the values are not found.I believe you should put your breakpoint/
NSLog
intoisEqual
and watch what is happening when values are compared.Also note that the dictionary keys are copied, so the equality problem can arise during copying.
相关问答
更多从NSMutableDictionary中获取NSMutableDictionary的值(Get the values from NSMutableDictionary inside NSMutableDictionary)
循环通过NSMutableDictionary(looping through an NSMutableDictionary)
iOS:无法在NSMutableDictionary中设置空值(iOS: can't set the null value in an NSMutableDictionary)
NSMutableDictionary返回null(NSMutableDictionary returning null)
NSMutableDictionary中的对象突然变为空(Object in NSMutableDictionary suddenly becomes null)
为什么NSUserDefaults无法保存NSMutableDictionary?(Why does NSUserDefaults fail to save NSMutableDictionary?)
将JSON解析为NSMutableDictionary问题(Parsing JSON into NSMutableDictionary issue)
NSMutableDictionary不接受某些字符(NSMutableDictionary not accepting certain characters)
无法使NSMutableDictionary工作(xcode)(Can't get NSMutableDictionary to work (xcode))
JSONRepresentation为NSMutableDictionary(JSONRepresentation for NSMutableDictionary)
相关文章
更多Solr 使用自定义 Query Parser
Solr 使用自定义 Query Parser
my php & mysql FAQ
Mysql错误:Ignoring query to other database解决方法
[How to] Make custom search with Nutch(v 1.0)?(转)
Solr与Mysql集成指南
Solr与Mysql集成指南
常用HQL(Hibernate Query Language)查询
solr学习笔记二-------solr query查询的参数
最新问答
更多python的访问器方法有哪些
使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
透明度错误IE11(Transparency bug IE11)
linux的基本操作命令。。。
响应navi重叠h1和nav上的h1链接不起作用(Responsive navi overlaps h1 and navi links on h1 isn't working)
在C中读取文件:“r”和“a +”标志的不同行为(Reading a File in C: different behavior for “r” and “a+” flags)
NFC提供什么样的带宽?(What Kind of Bandwidth does NFC Provide?)
元素上的盒子阴影行为(box-shadow behaviour on elements)
它看起来像只在Windows上的Chrome的错误。 我在Google Canary (Chrome 63)中也进行了测试,问题依然存在,所以有可能它不会很快修复。 这个问题是由overflow: auto引起的overflow: auto ,在你的情况下,它可以很容易地通过删除或设置为可见(默认)来解决。 但是 ,将鼠标悬停在右侧(顶部和底部)时,会出现滚动条。 一个解决方案可以设置overflow: hidden的身体,所以预期的结果是所需的。 我想指出,这不是一个很好的解决方案,但我建议暂
Laravel检查是否存在记录(Laravel Checking If a Record Exists)
这取决于您是否要以后与用户合作,或仅检查是否存在。 如果要使用用户对象(如果存在): $user = User::where('email', '=', Input::get('email'))->first(); if ($user === null) { // user doesn't exist } 如果你只想检查 if (User::where('email', '=', Input::get('email'))->count() > 0) { // user found
设置base64图像的大小javascript - angularjs(set size of a base64 image javascript - angularjs)
$scope.getData= function () { var reader = new FileReader(); reader.onload = $('input[type=file]')[0].files; var img = new Image(); img.src =(reader.onload[0].result); img.onload = function() { if(this.width > 640
Copyright ©2023
peixunduo.com All
Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!
Laravel检查是否存在记录(Laravel Checking If a Record Exists)
设置base64图像的大小javascript - angularjs(set size of a base64 image javascript - angularjs)
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!