Is it possible to select from an alias in mysql?

前端 未结 2 368
清歌不尽
清歌不尽 2021-01-27 07:02

I created a table alias named tbl, and I want to select from that. But I am unable to do this. I know that my code is not correct nor optimized, but I am simply tes

2条回答
  •  迷失自我
    2021-01-27 07:57

    try this out

    select
         case
             when exists (select username from tbl where  username = 'bob' and  password = 'pass') then 'Username Exists'
         else 'Username does not exist'
         end as existanse_column
    from  tbl
    limit 1
    

    DEMO HERE

提交回复
热议问题