mysql数据库如何查询多表返回一个值?

String sql = "select power from teacher,student,admin where id= ? and pass= ? ";

2个回答

sql少了关联(外键)条件,比如根据学生id进行关联,类似如下,多表建议设置别名

select power from teacher  as t,student as s,admin as a where id= ? and pass= ?
and t.student_id = s.student_id 
and s.student_id = a.student_id 
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问