在ColdFusion中,Part Number字段中具有字母C后面跟着数字的搜索结果。

huangapple go评论43阅读模式
英文:

Search result that has a C and a number after the C in the Part Number Field in ColdFusion

问题

在CFQuery的Where语句中,您可以使用以下条件来筛选以'C'后跟数字的零件号:

Where Part_Number Like 'C[0-9]%'

这将只显示类似于'C4560'的零件号,而不会显示像'CBT-BGA'这样的零件号。希望这对您有所帮助。

英文:

I have a search results page that lists part numbers that engineers have to work on, but I only want part numbers displayed on the results page that have a C and then a number after the C in the part number. This is done in ColdFusion. How do I write this in the Where statement in my CFQuery? If I write Where Part_Number Like 'C%', it lists all the parts that have anything after a C in the part number like CBT-BGA. I want it to find only part numbers like this: C4560. I also tried this: Where Part_Number Like '^C[0-9]', but this doesn't show any results. Thanks for your help.

答案1

得分: 0

我们需要知道您使用的数据库类型,以便为您提供正确的答案。您使用ColdFusion并不影响您需要生成的SQL结构。

如果您使用的是SQL Server,SQLShack建议您可以使用like操作符进行一些最小的模式匹配:

SELECT whatever FROM someTable WHERE someColumn LIKE '[C][0-9]%'

对于MySQL或PostgreSQL,语法可能会有所不同,但是一些快速搜索应该能找到正确的方法。

英文:

We need to know which database you're using to give you a proper answer. The fact that you're using ColdFusion has no bearing on the structure of the SQL you need to generate.

If you're using SQL Server, SQLShack says you should be able to use the like operator with some minimal pattern matching:

SELECT whatever FROM someTable WHERE someColumn LIKE '[C][0-9]%'

The syntax will likely be different for MySQL or Postgresql, but some quick searches should turn up the proper approach.

huangapple
  • 本文由 发表于 2023年5月11日 04:49:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/76222457.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定