如何匹配表格中的数据 [英] How can I match data in the table

查看:46
本文介绍了如何匹配表格中的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,
我有一张表格,其中有userid,qustions,answers列(3个是int字段)
我需要从表中获取匹配的用户ID.即我输入了2个值userid,但没有匹配项.根据此值,我应该获取匹配项...类似于输入ID的行,其中问题号和答案数相等应被检索.如何实现此目的?是否可以通过游标..但是游标会降低查询性能..


好吧..让我解释一下...
在我的应用程序中有一个调查表..并且我给了这些问题的答案选项...所以当用户保存数据时,答案号和问题号将存储在表中...所以我想检查谁对于特定的问题,所有这些用户都被标记为相同的答案..在这里,我传递了userid,并且表中不存在匹配项..使用PL SQL存储过程.该用户ID的问题和答案,然后检查其他人的答案是否相同...这里重要的一点是传递不匹配的号码,例如至少5或10或所有匹配项.
在此先感谢...

Hi there,
I have a table with the columns userid,qustions,answers(3 are int fields)
I need to get the matching userids from the table..i.e I input 2 values userid,and no of matches..according to this value I should get the match...the rows similar to the input id,where the question number and answer number are equal should be retrieved.. How to accomplish this? Is it possible by cursor..but cursor reduce the query performance..


Okay..let me explain...
In my application there is a questionnaire.. And i have given answer options for that questions...so when user save the data,the answer number along with question number will be stored in the table...so i want to check who all are the users marked the same answer,for a particular question.. Here I pass userid and no of matches should exist in the table..with PL SQL stored procedure..so the procedure should get the input user id,and get the question and answers of that userid then to check who others have the same answer...here one important thing is to pass the no of matches like atleast 5 or 10 or all matches..
Thanks in advance...

推荐答案

您没有说您正在使用哪个数据库.您不会说您正在使用哪种语言.您说要与输入ID相似".您将需要定义相似".通常,相似表示在某种程度上相同和几乎相同的那些.那么你想靠近多远?

如果您正在编写应用程序,那么似乎可以使用参数化查询".

如果您的数据库允许使用存储过程,那么如果使用纯SQL,则最明显的是参数化存储过程.

没有您的更多信息,很难做到更精确.
You do not say what database you are using. You do not say which language, if any, you are using. You say you want ''similar'' to the input id. You will need to define ''similar''. Normally similar means those that are the same and those that are nearly the same in some way. So how near do you want to be?

If you are writing an application then a Parameterized Query would seem to be the way to go.

If plain SQL then a Parameterized Stored Procedure would be the most obvious, if your database allows Stored Procedures.

Without more information from you it is difficult to be more precise.


这篇关于如何匹配表格中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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