473,396 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Multiple checks on one parameter?

56
Hi all,

I'm having a hard time creating a query with parameters. I have a table which contains ID numbers (not primary key) which are just a value attached to a customer. In a way like a password without which the user cannot continue to checkout on a site we're developing.

The problem is that we don't specify the exact format of this data and so need to make a check for a certain amount of zeros before the actual number. i.e. the values in the database can have a certain amount of zeros in front of the id number supplied by the customer. eg. "00456P" or "0000456P"...what we get from the user is 456P and we have to check if the value exists in the database whatever the number of zeros before the actual id number.

What I cant get to work is the following query where ? is the parameter passed from ASP.NET:

Expand|Select|Wrap|Line Numbers
  1. SELECT *  
  2. FROM tb_Ids 
  3. WHERE nr_id = ?    OR
  4.      nr_id = CONCAT('0', ?) OR
  5.      nr_id = CONCAT('00', ?) OR
  6.      nr_id = CONCAT('000', ?) OR
  7.      nr_id = CONCAT('0000', ?) OR
  8.      nr_id = CONCAT('00000', ?) OR
  9.      nr_id = CONCAT('000000', ?) OR
  10.      nr_id = CONCAT('0000000', ?);
I know the syntax is not correct (i am getting an error and am sure its cuz of the way I use the parameter) but it is somewhat similar to what I'm looking for.

In fact when i tested it on database with a query analyser it works fine i.e. if I replace the ? with '456P'

So my question is how do I make multiple checks on one parameter in a query. Please don't tell me to use Stored Procedures since I cannot in this case

Thanks a lot and sorry for the long post but its the only way I can make it clear
Apr 21 '08 #1
4 1588
pechar
56
Anyone Please??
I would appreciate anyone's help

Thanks
Apr 23 '08 #2
ronverdonk
4,258 Expert 4TB
Use a regular expression on this. So in order to select a value containing (prefix) 0-9 zeroes and chars ABC (your variable data), the statement is like
Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM tb_Ids 
  2.      WHERE nr_id REGEXP concat('^0{0,9}','ABC');
  3.  
Ronald
Apr 24 '08 #3
pechar
56
Use a regular expression on this. So in order to select a value containing (prefix) 0-9 zeroes and chars ABC (your variable data), the statement is like
Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM tb_Ids 
  2.      WHERE nr_id REGEXP concat('^0{0,9}','ABC');
  3.  
Ronald
Thanks a lot. I could marry you for this !!!!

I've been banging my head on the wall for ages!

Thanks again
Luk
Apr 25 '08 #4
ronverdonk
4,258 Expert 4TB
Thanks a lot. I could marry you for this !!!!

I've been banging my head on the wall for ages!

Thanks again
Luk
Glad it works for you. Btw: you can get the REGEXP conventions from the MySQL manual.

See you around.

Ronald
Apr 25 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: RJ | last post by:
We currently send product releases to our customers, and often have to include scripts that need to be ran on the Oracle databases (also do it for SqlServer customers, but we use a different set of...
8
by: Ralph Freshour | last post by:
I have multiple checkbox's created with an array name because I have many on the same web page - their names are like: frm_chk_delete frm_chk_delete frm_chk_delete frm_chk_delete etc. Here...
4
by: Leslaw Bieniasz | last post by:
Cracow, 20.09.2004 Hello, I need to implement a library containing a hierarchy of classes together with some binary operations on objects. To fix attention, let me assume that it is a...
4
by: Dave Parrin-Bull | last post by:
Hi all, I have been asked (nay told!) to do a quiz for a webpage at work, now I can do the basic things like getting the radio boxes up there and assign values to them but here is what they...
6
by: Mike Conklin | last post by:
This one really has me going. Probably something silly. I'm using dcount for a report to determine the number of different types of tests proctored in a semester. My report is based on a...
6
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing...
7
by: anthony.turcotte | last post by:
Hi, I've looked for a solution to this problem on google, read posts in this newsgroup and I still haven't found anything that could help me. Here's the scenario. 1. User accesses...
4
by: jedimasta | last post by:
Good evening all, I'm a relatively new to javascript, but I've been working with ColdFusion and PHP for years so I'm not necessarily ignorant, just stuck and frustrated. Using ColdFusion I'm...
2
by: Steve | last post by:
I'm looking for feedback on an authentication solution we are considering for an ASP.NET 2.0 project. The site will be accessed by both internal users who are logged into the Windows domain, and...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.