select instr(t.id,'&') as m_id, substr(id,m_id,5) from table1
像上面这样m_id作为重命名的字段名,能用在后面的substr里吗?因为有时instr(t.id,'&')这类的函数比较长,重复的写,会让sql很难看。
像上面这样m_id作为重命名的字段名,能用在后面的substr里吗?因为有时instr(t.id,'&')这类的函数比较长,重复的写,会让sql很难看。
from
(select instr(t.id,'&') as m_id from table1)
我帮你试过了,会报错:不能识别m_id。
如果你有很多地方要用instr(t.id,'&')的话就在外面再套一层select吧
但可以变通,请参考:SELECT SUBSTR(ID, m_id, 5)
FROM (selectt INSTR(t.id, '&') AS m_id FROM table1);
或者:
select substr(id,instr(id,'&'),5) from table1
你应该多看看sql的执行原理