简体   繁体   English

基于某些条件的SQL查询

[英]SQL query based upon some criteria

sir, it like searching function 先生,它像搜索功能

i need to search the table which has data stored in ms access table. 我需要搜索已将数据存储在ms访问表中的表。 i have create a text box for the contract no,username and date and need to search the table according to contract no or username or date. 我已经为合同编号,用户名和日期创建了一个文本框,需要根据合同编号或用户名或日期搜索表格。

for that i need a coding with solve the problem in single sql command. 为此,我需要一个编码来解决单个sql命令中的问题。 i have try it with where help is a table,search-test is form. 我在帮助是表格的地方尝试过,搜索测试是表格。

when the help(table).cont_no(field) is equal to search-test(form name).cont_no(text box field) 当help(table).cont_no(field)等于search-test(form name).cont_no(text box field)

SELECT 
  * 
FROM 
  Help 
WHERE 
  (((Help.cont_no)=[Forms]![search-test]![cont_no])) 
  OR (((Help.username)=[Forms]![search-test]![username]) 
  or ((Help.date)=[Forms]![search-test]![cbo_date]));

hope you will understand my view 希望你能理解我的看法

Assuming that contract no and user name are Text type fields you need to enclose the strings in apostrophe's to enclose text/strings 假设合同编号和用户名是“文本类型”字段,则需要将字符串括在撇号中以将文本/字符串括起来

something like 就像是

DoCmd.RunSQL "SELECT Help.cont_no, Help.Req_no, Help.Br_name, Help.br_code, Help.Remarks, Help.Status, Help.username, Help.case, Help.date FROM Help DoCmd.RunSQL“ SELECT Help.cont_no,Help.Req_no,Help.Br_name,Help.br_code,Help.Remarks,Help.Status,Help.username,Help.case,Help.date来自帮助

WHERE (((Help.cont_no)=" & "'" & [Forms]![search-test]![cont_no])) & "'" & " OR ....

Thanks 谢谢

I believe you have duplicated your question here: SQL query based upon some criteria 我相信您在这里重复了您的问题: 基于某些条件的SQL查询

If not, please elaborate a bit more on the new problem you're having. 如果不是这样,请详细说明您遇到的新问题。 Thanks 谢谢

EDIT: Actually, you have triplicated your question SQL query based on criteria 编辑:实际上,您已经根据条件将问题SQL查询重复了三份

EDIT: If you add comments or edit your original question it will be automatically bumped. 编辑:如果您添加评论或编辑您的原始问题,它将被自动颠簸。 There is no reason to deliberately post your questions multiple times... not only because of clutter but also because people trying to help you will not be able to see the progress of your question so far 没有理由多次故意发布您的问题……不仅因为混乱,而且因为试图帮助您的人们到目前为止还无法看到问题的进展

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM