SQL Query trouble

SQL Query trouble

am 17.01.2008 21:30:18 von marauder78

hello all,
I have a form with multiple chechboxes. Depending upon what the user chooses
I need to make a select from a database with 6 tables. I pass the results
from the form to the SQL statement up to the moment I need to put in a where
request.form>0 clause. The big issue is that the request form may look like
str1,str2,str3,str4 if the user selects them all.

Maybe u can help because I'm completely lost.
Here is the code:
------FORM------


width="100%">



















Choose County

Alba  
Arges  
Arad  
Braila  
Botosani  
Brasov  
Buzau  
Cluj  
Calarasi  
Choose Culture

Grau  
Porumb  
Floare  
Rapita  
Soia  

Directia Agricola
 
Simpozion  
APIA  
Altele  



  type="submit" name="Submit" value="Add Contact">


---------processquery.asp--------------

<%
dim strjudet,strcultura,strsursa

strjudet=request("Judet")
strjudet=Replace(strjudet, ",","','")
strjudet=Replace(strjudet, " ","")
strsursa=request("Sursa")
strsursa=Replace(strsursa, ",","','")
strsursa=Replace(strsursa, " ","")



strcultura=request("Cultura")
%>
<%
Set RS = Server.CreateObject("ADODB.Recordset")
RS.ActiveConnection = Conn

'SQL = "SELECT * FROM Customer INNER JOIN Address ON Customer.ID=Address.ID
INNER JOIN FarmDetails ON Address.ID=FarmDetails.ID WHERE Address.County IN
('"&strjudet&"')"
SQL = "SELECT * FROM Customer,Address,FarmDetails,InfoDetails WHERE Customer.
ID=Address.ID AND Customer.ID=FarmDetails.ID AND Customer.ID=InfoDetails.ID
AND Address.County IN ('"&strjudet&"') AND Source IN ('"&strsursa&"') AND
each Item in strcultura>0"????how do I go about that?

RS.Open SQL, Conn, 1, 3




If NOT (RS.BOF AND RS.EOF) Then%>

<% While (NOT RS.EOF)

%>


Thanks

Re: SQL Query trouble

am 18.01.2008 22:25:18 von Jon Paal

you will need to test for each selected value and then build up a WHERE clause according to the results.

then append the constructed WHERE clause into your SQL statement