字段组合查询

刚有网友问及,数据表的姓与名是分开存储,但查询时,传入的是全名,怎样实现查询。

Insus.NET简单写了一个例子,可以参考之:

 

IF OBJECT_ID('[dbo].[Employee]') IS NOT NULL
    DROP TABLE [dbo].[Employee]

CREATE TABLE [dbo].[Employee]
(
    [FirstName] NVARCHAR(40),
    [LastName] NVARCHAR(40)
)
GO
INSERT INTO [dbo].[Employee] ([FirstName],[LastName]) VALUES (N'',N''),(N'',N''),(N'',N'')


SELECT [FirstName],[LastName] FROM [dbo].[Employee] WHERE ([FirstName] + [LastName]) = N'李四'
Source Code

 

posted @ 2019-05-12 21:54  Insus.NET  阅读(499)  评论(0编辑  收藏  举报