需要sql来压缩请求并添加和/或语句 [英] need sql to condense request and add an and/or statement

查看:57
本文介绍了需要sql来压缩请求并添加和/或语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在sql中每个pt_type可以有几行不同的信息,每行都有不同的pt_reference


所以单词1和2可能在同一行,但是单词3可能在一行中不同的行但具有相同的d_id,但如果所有3个值都匹配,那么我想知道唯一的d_id。对于每个独特的匹配结果。


在下面的情况下,将显示1941和2991


是否也有一个和/或excel语句的类型?我在下面的查询中注意到我需要它。



谢谢



id d_id pt_type pt_ref pt_value

3278764 69765 11 999 J0SB

4658482 67811 11 8 screen

2892238 47499 0 1 CRL Custom Finish P7 Series 36"末端接头旋转接头栏杆套件

4069940 1941 11 4这个

2793773 8756 0 1 CRL黑色压铸滑动门拉门2-3 / 8螺丝孔

2892239 47500 0 1 CRL Custom Finish P7 Series 36"角柱旋转接头栏杆套件

4161303 14657 11 1交易

4176252 29539 11 2栏杆

4184049 1941 11 9

4188079 33720 11 3栏杆

2762021 1941 0 1 theother

2762022 34055 1 1 C1DP42BRZ_34055.gif

3254121 3236 5 1面直径:: 2英寸(50.8毫米)

5001800 31146 16 1 CRL Abrazadera de manguitoapresiónparacristal,90 grados,en cobre cepillado antiguo

2762024 2991 1 2这是一个测试

4191045 2991 11 2那是两个

2794393 2991 1 1另一个


展开 | 选择 | Wrap | 行号

解决方案

这是真的不清楚。它几乎不是一个问题。


打扰一下,如果我猜测你要问的是什么,但是如果你想识别所有这些[d_id ]在您的数据中多次引用的值(似乎是您想要的)然后尝试:

< span class =codeLinkonclick =Blur(this,this.parentNode.parentNode,getChildren(this),true);>展开 | 选择 | Wrap | 行号


请让我澄清


此表中的每个pt_id都是一个独特的记录。


此表中的每个pt_productid可能不是唯一的,并且可能有多个条目


在附加的Wor上d doc,有几个记录的pt_productid为67811和5817

我需要一个查询,它将返回任何匹配的单个,两个或三个单词输入匹配的唯一pt_productid。 br />

输入会查看所有pt_type'的0或11



僵硬优雅的栏杆


它会返回pt_productid记录5817

或搜索屏幕交易硬件


它会返回67811的pt_productid记录


---------


旁注:所有搜索到的三个单词都需要匹配,如果这个复杂的东西是可能的话,找到三个单词中的两个的选项也会很好。





附图像
sql example.jpg (87.8 KB,122 views)

我想我们差不多了,但是你的解释说了一件事(你在找到任何搜索词的任何ID之后),而你的例子暗示另一个(所有提供的搜索)单词必须匹配)。在尝试帮助一些匹配的SQL之前,了解一下这些是有帮助的。


in sql each pt_type can several different lines of information, each with a different pt_reference

so word 1 and 2 might be in the same row, but word 3 might be in a different row but have the same "d_id", but if all 3 values are matched, then I want to know the unique "d_id" for each unique matching result.

in the case below, 1941 and 2991 would be displayed

is it also to have an and/or type of excel statement? I noted in the query below where I need it.


THANK YOU


id d_id pt_type pt_ref pt_value
3278764 69765 11 999 J0SB
4658482 67811 11 8 screen
2892238 47499 0 1 CRL Custom Finish P7 Series 36" End Post Swivel Fitting Railing Kit
4069940 1941 11 4 this
2793773 8756 0 1 CRL Black Die Cast Sliding Screen Door Pull With 2-3/8" Screw Holes
2892239 47500 0 1 CRL Custom Finish P7 Series 36" Corner Post Swivel Fitting Railing Kit
4161303 14657 11 1 TRANSACTION
4176252 29539 11 2 railing
4184049 1941 11 9 that
4188079 33720 11 3 railing
2762021 1941 0 1 theother
2762022 34055 1 1 C1DP42BRZ_34055.gif
3254121 3236 5 1 Face Diameter::2 in (50.8 mm)
5001800 31146 16 1 CRL Abrazadera de manguito a presión para cristal, 90 grados, en cobre cepillado antiguo
2762024 2991 1 2 this is a test
4191045 2991 11 2 and that is two
2794393 2991 1 1 other one



Expand|Select|Wrap|Line Numbers

解决方案

This is really not clear. It''s barely even a question at all.

Excuse me then if my guess as to what you are trying to ask is off, but if you want to identify all those [d_id] values that are referred to more than once in your data (as seems to be what you want) then try :

Expand|Select|Wrap|Line Numbers


Please let me clarify

Each pt_id in this table is a unique record.

Each pt_productid in this table may not be unique, and may have multiple entries

On the attached Word doc, there are several records with a pt_productid of 67811 and 5817

I need a query that will return any matching unique pt_productid that matches the one, two, or three word input.

The input would look at all pt_type''s of 0 or 11

So in this case if I looked for

stiff elegant railing

it would return a pt_productid record of 5817

or a search for screen transaction hardware

it would return a pt_productid record of 67811

---------

side note: all three searched for words need to be matched, an option for finding two of the three words would also be good if something this complex is possible.

Attached Images
sql example.jpg (87.8 KB, 122 views)


I think we''re nearly there, but your explanation says one thing (you''re after any ID where any of the search words are found) while your examples imply another (that all provided search words must be matched). It would help to know which of these you mean before attempting to help with some matching SQL.


这篇关于需要sql来压缩请求并添加和/或语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆