如何使用in子句中的msd访问条件进行选择

编程入门 行业动态 更新时间:2024-10-28 02:31:25
本文介绍了如何使用in子句中的msd访问条件进行选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用MS Access 2007中的in子句为select数据编写查询。 我尝试了什么: 我的查询是 从InvoiceInfo中选择*,其中[InvoiceNo]包含('INV0001,INV0010') 但它返回0行,其中在访问表中该值存在

I write a query for select data using in clause from MS Access 2007. What I have tried: my query is Select * from InvoiceInfo where [InvoiceNo] contains ('INV0001,INV0010') but its return 0 rows, where in access table this values is exists

推荐答案

您正在检查特定的string:INV0001,INV0010所以除非那个确切的字符串 - 即两个用逗号分隔的发票号 - 位于至少一行中,否则你将不会返回任何行。你不会得到其中一个发票号或其他号码的行,或找到的行,但也用空格分隔。 如果你的DB包含逗号分开的发票编号,它设计得很糟糕:你应该使用一个单独的表,其中包含每个发票号以及一个与原始表相关的外键 - 并使用JOIN查询获取数据。 如果没有,你可能需要一个IN子句: You are checking for a specific string: "INV0001,INV0010" so unless that exact string - i.e. both invoice numbers separated by a comma - is located in at least one row you will get no rows returned. You will not get rows where one of the invoice numbers or the other are found, or where there are found but also separated by a space. If your DB contains comma separated invoice numbers, that it's badly designed: you should be using a separate table that contains each single invoice number together with a Foreign Key that relates back to your original table instead - and fetch data using a JOIN query. If it doesn't, you may need an IN clause instaed: SELECT * FROM InvoiceInfo WHERE InvoiceNo IN ('INV0001', 'INV0010');

你能尝试这样吗 Can you try like this SELECT * FROM InvoiceInfo WHERE InvoiceNo IN('INV0001','INV0002','INV0003');

更多推荐

如何使用in子句中的msd访问条件进行选择

本文发布于:2023-10-14 21:32:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1492273.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   句中   条件   msd

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!