代码
select employee_id,concat(last_name,first_name) as allname ,length(concat(last_name,first_name)),instr(last_name,"a") "contains 'a'?"
from employees
where substr(job_id,4)="rep";
以上代码可正常查询!
老师,看下这个,我对concat函数返回结果起别名了,用length函数时嵌套可以算总长,能正常执行,但直接用length(allname)就会报错。如下,别名在当前语句内不可以被再次引用么?
select employee_id,concat(last_name,first_name) as allname ,length(all_name),instr(last_name,"a") "contains 'a'?"
from employees
where substr(job_id,4)="rep";
[SQL] select employee_id,concat(last_name,first_name) as allname ,length(all_name),instr(last_name,"a") "contains 'a'?"
from employees
where substr(job_id,4)="rep";
[Err] 1054 - Unknown column 'all_name' in 'field list'