刚有网友问及,数据表的姓与名是分开存储,但查询时,传入的是全名,怎样实现查询。
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'李四'