Solved

wildcards for select query in sql server and dreamweaver in asp..

Posted on 2006-11-20
5
242 Views
Last Modified: 2009-07-29
hi,

i am using ms sql 2005 and dreamweaver with asp and I am trying to query a table for a member number and also a scheme type..  There are about 30 scheme types that can have access to the site and the rest are blocked access..  I am trying something like the code below, with no Joy!!    The MMColParam is a session variable with their user id stored in it and then I want to list the acceptable codes and if the code is like one in the list display the data, if the code is not in the list, give them an error..  I would really like to use a wildcard instead of a massive statement with loads of ands in it..  The format is fairly simple e.g. dir1f, dir2f, dir3f etc.. some of the others are corp1f, corp2f etc...  

They first log in and this is the page they get sent to, so the userid is always going to be in the session....

SELECT *
FROM dbo.[_authentication]
WHERE user_id = MMColParam AND [current_scheme] LIKE 'DIR_' OR [current_scheme] LIKE 'CORP_'

Any ideas or pointers would be great....

cheers
0
Comment
Question by:ckawebcreation
  • 2
  • 2
5 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17978069
SELECT *
FROM dbo.[_authentication]
WHERE user_id = MMColParam AND [current_scheme] LIKE 'DIR_%' OR [current_scheme] LIKE 'CORP_%'
0
 
LVL 28

Accepted Solution

by:
imran_fast earned 125 total points
ID: 17978342
Appy parenthesis after the end

SELECT *
FROM dbo.[_authentication]
WHERE user_id = MMColParam AND( [current_scheme] LIKE 'DIR%' OR [current_scheme] LIKE 'CORP%' )
0
 
LVL 28

Expert Comment

by:imran_fast
ID: 17978347
i mean to say "Apply Parenthesis after the AND"
0
 

Author Comment

by:ckawebcreation
ID: 17979788
cheers guys, i will give it  a go and let you know how I get on!!
0
 

Author Comment

by:ckawebcreation
ID: 17979978
good skills imran!!!
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question