473,508 Members | 2,355 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sql query with a stringfunction

Hi...

I have a problem. I need a query that can handle to search throu a string, here
called mylist. if lF08.postNr is in mylist all is ok.

mylist="115, 116, 117, 118, 119, 120"

Something like this

strSQ = "SELECT DISTINCT * from lF08, m08 where
instr(lF08.postNr,mylist) AND lF08.memberNr=m08.memberNr order by ort DESC"

I know i can't use the function instr, but how can i solve this. Is there
a function for this? I use sql-server 2000

Regards mikael
Jul 20 '05 #1
2 1121

"majsen" <mi****@home.staertesjoen.se> wrote in message
news:58**************************@posting.google.c om...
Hi...

I have a problem. I need a query that can handle to search throu a string,
here
called mylist. if lF08.postNr is in mylist all is ok.

mylist="115, 116, 117, 118, 119, 120"

Something like this

strSQ = "SELECT DISTINCT * from lF08, m08 where
instr(lF08.postNr,mylist) AND lF08.memberNr=m08.memberNr order by ort
DESC"

I know i can't use the function instr, but how can i solve this. Is there
a function for this? I use sql-server 2000

Regards mikael


Assuming myList is a string, then one way is to build the query string on
the front end:

strSQ = "
SELECT DISTINCT *
from lF08 join m08
onlF08.memberNr=m08.memberNr
where lF08.postNr in (" + myList + ")
order by ort DESC"

This article explains how to use a server-side approach:

http://www.sommarskog.se/arrays-in-sql.html

Simon
Jul 20 '05 #2
Thanks!
Nice pice of code...
Regards mikael

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3413
by: jaysonsch | last post by:
Hello! I am having some problems with a database query that I am trying to do. I am trying to develop a way to search a database for an entry and then edit the existing values. Upon submit, the...
29
2477
by: shank | last post by:
1) I'm getting this error: Syntax error (missing operator) in query expression on the below statement. Can I get some advice. 2) I searched ASPFAQ and came up blank. Where can find the "rules"...
9
3109
by: netpurpose | last post by:
I need to extract data from this table to find the lowest prices of each product as of today. The product will be listed/grouped by the name only, discarding the product code - I use...
3
5372
by: Harvey | last post by:
Hi, I try to write an asp query form that lets client search any text-string and display all pages in my web server that contain the text. I have IIS 6.0 on a server 2003. The MSDN site says...
4
2133
by: Diamondback | last post by:
I have two tables, WIDGETS and VERSIONS. The WIDGETS table has descriptive information about the widgets while the VERSIONS table contains IDs relating to different iterations of those widgets...
14
3853
by: Dave Thomas | last post by:
If I have a table set up like this: Name | VARCHAR Email | VARCHAR Age | TINYINT | NULL (Default: NULL) And I want the user to enter his or her name, email, and age - but AGE is optional. ...
2
18684
by: Dom | last post by:
I need to run a query based on a query in Access. The second query has a number of conditions which all work well, but there is one more contition I need to set to make it run properly. the...
5
10580
by: Ryan Hubbard | last post by:
Is it possible to get the recordset from an open query window? So you run the query. The window is open. Can vba retrieve this data?
0
3484
by: starace | last post by:
I have designed a form that has 5 different list boxes where the selections within each are used as criteria in building a dynamic query. Some boxes are set for multiple selections but these list...
0
7379
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
7493
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
5625
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,...
1
5049
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4706
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3192
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1550
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.