简体   繁体   中英

Select query with custom column and value of other column

I want to have a query that have a custom column and have some value of other column

Here is example of a table

Table 1 : id, name, emp_id

I want to have input like this

id | name | emp_id | process      |
1  | John | 002    | Work of John |

The process is just custom column I want to do it in Select query. Laravel eloquent query much more appreciated, since I'm doing it in laravel.

This is what I tried:

Select id, name, emp_id, "Work of " + name as process, 
from table1

But it's not working. I also want to add 2 or more column value in custom column.

Thanks

I think you are looking for concat() :

select id, name, emp_id, concat('Work of ', name) as process
from table1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM