使用列组合获取emp_id [英] Getting emp_id using a combination of columns
问题描述
您好,我正在尝试通过使用名字和姓氏的组合从我的表中检索emp_id,实际上是在我的应用中,我允许用户从列表框中选择名称,并从user_details表中填充列表框从名字和姓氏列之间插入一个空格,即"Mohit Roy",如果用户选择该名称,我希望我的应用使用该名称的emp_id进行某些操作,请帮助我编写查询以检索emp_id使用名字和姓氏列,中间有一个空格.在此先感谢.
Hi, I am trying to retrieve the emp_id from my table by using a combination on first and last name, actually in my app i m allowing the user to select name from a list box, and filling the list box from the user_details table from first and last name column with a space in between, i.e. "Mohit Roy", if the user select the name i want my app to do some operation using the emp_id of that name, please help me to write the query which can retrieve the emp_id using first and last name column with a space between in it. Thanks in advance.
推荐答案
Mysql:
Mysql:
SELECT CONCAT_WS('' '', `name`, `surname`) AS `emp_id` FROM `employees`
PostgreSQL:
PostgreSQL:
SELECT name || '' '' || surname FROM employees
SQLServer 2005:
SQLServer 2005:
SELECT name + '' '' + surname FROM employees
检查此;)
check this ;)
这篇关于使用列组合获取emp_id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!