我有2张桌子
用户
我想展示课程作者=姓名+来自用户表的名字的课程
我试过
SELECT * FROM `courses` as c WHERE EXISTS ( SELECT * from `users` as u WHERE u.id_user = '63' AND c.author = CONCAT(u.name, ' ', u.surname)
我收到错误
您的SQL语法有错误;检查手册 对应于您的MySQL服务器版本,以便使用正确的语法 靠近''在第1行
感谢。
答案 0 :(得分:2)
你可以JOIN
这两个表:
SELECT c.* FROM `courses` as c
JOIN `users` as u
ON c.author = CONCAT(u.name, ' ', u.surname)
WHERE u.id_user = '63'
答案 1 :(得分:1)
connect system/a@xe as sysdba
create user pta identified by pta
/
grant dba to pta
/
grant create user to pta
/
grant alter user to pta
/
grant create role to pta
/
grant drop any role to pta
/
grant select on dba_role_privs to pta
/
grant select on role_tab_privs to pta
/
grant select on dba_roles to pta
/
你需要加入这里。
答案 2 :(得分:-1)
尝试
select * from courses where author in (select concat(name,' ',surname)
from Users);