weixin_43906969
一峰说
采纳率0%
2020-05-31 16:08 阅读 161

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

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

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • syyyyyyyyyyyyyyh syyyyyyyyyyyyyyh 2020-06-01 10:20
  • hjs218 Json-Huang 2020-06-03 20:49

    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 
    
    点赞 评论 复制链接分享

相关推荐