问题描述
hi guys i有这个商店程序
从 dbo.DeleteList 其中(Title2 喜欢 ' % - %') 选择 * 来自 dbo.DeleteList 其中(Title2 NOT 喜欢 ' % - %')
我希望得到第一行的结果然后是第二行的结果 你有什么想法吗? i使用UNION但它不起作用。
解决方案你可以尝试一些像... 。
选择 * 来自 dbo.DeleteList 订单 按 案例 当 Title2 喜欢 ' % - %' 然后 1 其他 2 结束
嘿那里, 你试过
UNION ALL
, 选择 *来自dbo.DeleteList where (Title2 喜欢 ' % - %') UNION ALL 选择 * 来自 dbo.DeleteList 其中(Title2 NOT 喜欢 ' % - %')
希望它有所帮助。 Azee ......
< blockquote>我想添加的条件令人困惑.. 如果某些记录是在类似'% - %'下获取的那么显然那些其他记录不会被提取,因为他们做了不满足条件。 两个相反的相反条件类似于使用 SELECT *无任何条件 即SELECT * FROM TABLE1 您将获得满足这两个条件的记录。
hi guys i have this store procedure
select * from dbo.DeleteList where (Title2 like '%-%')
select * from dbo.DeleteList where (Title2 NOT like '%-%')
and i want get result of first line then result of second line are you hava an idea? i use UNION but it not work.
解决方案 u can try some thing like...select * from dbo.DeleteList
Order by Case When Title2 like '%-%' Then 1 Else 2 End
Hey there,
Have you tried UNION ALL
,
select *from dbo.DeleteList where (Title2 like '%-%')
UNION ALL
select * from dbo.DeleteList where (Title2 NOT like '%-%')
Hope it helps. Azee...
I guess the conditions added are confusing.. If some records are fetched under like '%-%' then obviously then others are not fetched because the they did not satisfy the condition. Two contradictary opposite conditions is similar in using SELECT * without any condition i.e SELECT * FROM TABLE1 where you will get records satisfying both the condition.