我有两张桌子:
Catalog(ID, CourseName, PreReq, Professor)
PreviousCourses(Username, PreviousCoursesID, Grade)
PreviousCoursesID
对应于目录中的ID
。我试图使用这种关系访问CourseName。
这是我的问题:
Select CourseName from Catalog where ID = (Select PrevCoursesID from PreviousCourses where Username = 'admin')
执行但返回空集。
Select PrevCoursesID from PreviousCourses where Username = 'admin'
查询本身会返回PrevCoursesID
,所以我不明白为什么我的嵌套查询无效。
答案 0 :(得分:0)
ImageView im = (ImageView)findViewById(R.id.picassotest);
Picasso picasso = new Picasso.Builder(this).listener(new Picasso.Listener() {
@Override
public void onImageLoadFailed(Picasso picasso, Uri uri, Exception exception) {
exception.printStackTrace();
}
}).build();
picasso.with(this).setLoggingEnabled(true);
picasso.with(this).load("http://lacuadramagazine.com/wp-content/uploads/sangeh-monkey-forest-101.jpg").into(im);
需要使用" IN"而不是" ="像这样
Select CourseName from Catalog where ID = (Select PrevCoursesID from PreviousCourses where Username = 'admin')
因为它是一组值而不是单个值。检查超过1个值时,需要使用IN关键字。这与
相同Select CourseName from Catalog where ID IN (Select PrevCoursesID from PreviousCourses where Username = 'admin')