我从SurrealQL大学重写了一些旧的SQL问题,以学习surrealDB,但经过几天的思考,我无法解决这个问题:
找到所有来自同一个系的学生和教授,他们共同度过生日。
这是如何在SQL中解决这个问题的:
select st.stname, pf.profname, st.stbmonth, st.stbday
from STT st
join PROFT pf on st.stdepid = pf.profdepid
and st.stbmonth = pf.profbmonth
and st.stbday = pf.profbday;这是我最好的尝试:
select *, ->stdep->dep<-profdep<-prof from student;这给了我,每个学生都有一个来自同一个系的教授名单。问题是没有办法根据学生来过滤教授的名单。
应该工作但不起作用的查询:
select *, ->stdep->dep<-profdep<-prof[where profbday == stbday && profbmonth == stbmonth] from student;似乎你不能在教授的背景下访问学生的属性。
我认为,在SurrealQL中,并不是所有的查询都是可能的。
发布于 2022-09-29 08:24:20
经过几天的修补,我终于解决了!
select st.stname as stname, prof.profname as profname, st.stbmonth as bmonth, st.stbday as bday
from (select id as st, ->stdep->dep<-profdep<-prof as prof
from student split prof)
where (prof.profbday == st.stbday)
and (prof.profbmonth == st.stbmonth);https://stackoverflow.com/questions/73878943
复制相似问题