在Sql中选择查询........ [英] Select query In Sql........
本文介绍了在Sql中选择查询........的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Sql中我的查询就像..
SELECT *
FROM ProductMaster
WHERE CatalogId = ' < span class =code-string> 1007'
AND SubCode LIKE ' %A%'
或 SubCode LIKE ' %B%'
AND EntryUser = ' Green'
AND (
ProductMasterId!= ' 1000')
在输出中我不希望具有'1000'的行作为ProductMasterId b但是这行仍然是输出,所以任何解决方案
解决方案
看起来像OR条件的问题。尝试:
SELECT *
FROM ProductMaster
WHERE CatalogId = ' 1007'
AND (SubCode LIKE ' %A%'
或 SubCode LIKE ' %B%')
AND EntryUser = ' Green'
AND (
ProductMasterId!= ' 1000')
不等于是<>在SQL中。
尝试将其改为,看看会发生什么。
这应该是你的查询:
SELECT *
FROM ProductMaster
WHERE CatalogId = 1007
AND SubCode LIKE'%A%'
OR SubCode LIKE '%B%'
AND EntryUser ='Green'
AND ProductMasterId<> 1000
这是正确的语法,如果您的逻辑正确,它将起作用。尝试一次删除where子句的一部分并查看它的位置。
您好可以尝试此查询的
SELECT * 来自( select *
FROM ProductMaster
WHERE (CatalogId = 1007 AND (SubCode LIKE ' %A%' 或 SubCode < span class =code-keyword> LIKE ' %B%') AND EntryUser = ' Green')) as x 其中 x.ProductMaster Id<> 1000
问候,
Mubin
In Sql My Query is like ..
SELECT *
FROM ProductMaster
WHERE CatalogId = '1007'
AND SubCode LIKE '%A%'
OR SubCode LIKE '%B%'
AND EntryUser = 'Green'
AND (
ProductMasterId != '1000')
In Output i do not want the Row that has '1000' as ProductMasterId but still this row is coming in output so any solution for this
解决方案
Looks like a problem with the OR condition. Try:
SELECT * FROM ProductMaster WHERE CatalogId = '1007' AND (SubCode LIKE '%A%' OR SubCode LIKE '%B%') AND EntryUser = 'Green' AND ( ProductMasterId != '1000')
"Not equal" is "<>" in SQL.
Try changing it to that and see what happens.
This should be your query:
SELECT * FROM ProductMaster WHERE CatalogId = 1007 AND SubCode LIKE '%A%' OR SubCode LIKE '%B%' AND EntryUser = 'Green' AND ProductMasterId <> 1000
This is proper syntax and will work provided your logic is correct. Try removing one section of your where clause at a time and see where that gets you.
Hi you can try this query
SELECT * from( select * FROM ProductMaster WHERE (CatalogId = 1007 AND (SubCode LIKE '%A%' OR SubCode LIKE '%B%' )AND EntryUser = 'Green')) as x where x.ProductMasterId <> 1000
Regards,
Mubin
这篇关于在Sql中选择查询........的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文