查询name,要求
matches on first, middle or last name, ordered by last name matches first
就是对输入条件进行first, middle or last name上的匹配,结果集要按照last name有匹配的排在前面排列。
matches on first, middle or last name, ordered by last name matches first
就是对输入条件进行first, middle or last name上的匹配,结果集要按照last name有匹配的排在前面排列。
解决方案 »
- 高分求购数据结构问题
- sql2005客户端连接2008的问题
- union 与 union all 有什么区别
- %%急等??几个经典的SQL语句,再线请求版主和高手帮助,谢谢!解决后立即结贴,有不明白的可再线问,我等待,谢谢!!!!!!!!!!!!!!!!!!!!!
- 简单问题,得到答案立即给份!!!
- 数据显示
- 请教一个"游标已存在"的问题
- oracle使用有表复制表
- 请教:新增一条记录时触发程序更新另一个表,这时再用事务恢复,哪么发生在触发程式中的动作是否也被一起恢复呢?谢谢!!!
- 紧急求助:sql server 2000数据同步问题求高手赐教
- 用标准的SQL语句怎样通过字段名判断表中是否包含这个字段
- 恢复数据库备份的时候,特别慢
看不明白
a b c
b c a
c a b
三条记录查询条件 a 输出
b c a
a b c
c a b不用union行不行?
if object_id('tempdb.dbo.#T') is not null drop table #T
create table #T (firstname varchar(11),middlename varchar(11),lastname varchar(11))
insert into #T
select 'a','b','c' union all
select 'b','c','a' union all
select 'c','a','b'select * from #T where firstname='a' or middlename='a' or lastname='a' order by charindex('a',lastname) desc, lastname/*
firstname middlename lastname
----------- ----------- -----------
b c a
c a b
a b c
*/
where firstname = @name
or middlename = @name
or lastname = @name
order by lastname
select * from tb ... last name
union all
select * from tb ... first
....