1)如果给定的邮件ID与其邮件ID匹配,则从3(学生,教师,校友)表访问密码
2)我只想为这三个用户编写一个密码恢复程序
从一个表中访问一个密码的代码是
select password from current_student where mail_Id='"+mail_Id+"'
另一个代码
(SELECT PASSWORD AS r_password,mail_Id AS r_mail_Id FROM current_student HAVING mail_Id = 'mahender0791@gmail.com') UNION (SELECT PASSWORD AS r_password,mail_Id AS r_mail_Id FROM dept_Staff HAVING mail_Id = 'mahender0791@gmail.com') UNION (SELECT PASSWORD AS r_password,mail_Id AS r_mail_Id FROM alumni HAVING mail_Id = 'mahender0791@gmail.com')
,错误消息是
Query: (select password as r_password,mail_Id as r_mail_Id from current_student HAVING mail_Id = 'mahender0791@gmail.com') UNION (selec...
Error Code: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'HAVING mail_Id = 'mahender0791@gmail.com')
LIMIT 0, 1000' at line 1
答案 0 :(得分:1)
可能是这样的:
(SELECT PASSWORD AS r_password,mail_Id AS r_mail_Id FROM current_student HAVING r_mail_Id = 'mahender0791@gmail.com') UNION
(SELECT PASSWORD AS r_password,mail_Id AS r_mail_Id FROM dept_Staff HAVING r_mail_Id = 'mahender0791@gmail.com') UNION
(SELECT PASSWORD AS r_password,mail_Id AS r_mail_Id FROM YOUR_TABLE_NAME HAVING r_mail_Id = 'mahender0791@gmail.com')
YOUR_TABLE_NAME>>使用相应的表名更改此表名。
答案 1 :(得分:1)
(SELECT PASSWORD AS r_password,mail_Id AS r_mail_Id FROM current_student HAVING r_mail_Id = 'xx') UNION (SELECT PASSWORD AS r_password,mail_Id AS r_mail_Id FROM dept_Staff HAVING r_mail_Id = 'xx') UNION (SELECT PASSWORD AS r_password,mail_Id AS r_mail_Id FROM alumni HAVING r_mail_Id = 'xx')
这将起作用