Consegui em partes. O Código agora esta funcionando legal com apenas um problema, o mais importante. Ele só lista as cidades que estão em primeiro. Ele não passa para o resgistro seguinte que esta depois da virgula. Exemplo: AMERICANA, BARAO GERALDO, CAMPINAS Ele só esta me trazendo a listagem dos registros que tem a cidade de AMERICANA. Se caso a primeira cidade seja NOVA ODESSA, ele não percorre depois da virgula para me listar as outras cidades depois da virgula como HORTOLANDIA, SUMARE. Exemplo: NOVA ODESSA, HORTOLANDIA, SUMARE É possível fazer isso? Se puderem me ajudar, ficarei muito grato. <%
'Option Explicit
%>
<!--#include file="../includes/conexao/conexao.asp"-->
<%
dim ObjRS_campanha, SQL, ObjRS_cidade, ObjRS_cliente%>
<%
Call abre_conexao
%>
<%
str_id_cliente = Request("id_cliente")
%>
<%
Set ObjRS_campanha = Server.CreateObject("ADODB.RecordSet")
SQL = "SELECT * FROM tb_cadastro WHERE id_cliente = '"& str_id_cliente &"'"
Set ObjRS_campanha = ObjCon.Execute(SQL)
if Not ObjRS_campanha.EOF Then
str_cidade = ObjRS_campanha("cidade")
End if
Set ObjRS = Server.CreateObject("ADODB.RecordSet")
SQL = "SELECT * FROM tb_clientes WHERE cliente_ativo='1'"
if str_cidade <> "" Then
Dim arraycidade
arraycidade = split(str_cidade,",",-1,1)
For i = LBound(arraycidade) To UBound (arraycidade)
if i <> UBound (arraycidade) Then
separador = ","
Else
separador = ""
End if
if i > 0 Then
junta5 = junta5 &"'"& mid(arraycidade(i),1) &"'"& separador
Else
junta5 = junta5 &"'"& arraycidade(i) &"'"& separador
End if
Next
SQL = SQL & " and cidade in ("& junta5 &")"
End if
Set ObjRS = ObjCon.Execute(SQL)
%>
<%
Do Until ObjRS.EOF
%>
<%=ObjRS("id_cliente")%> - <%=ObjRS("nome")%> - <%=ObjRS("cidade")%><br />
<%
ObjRS.MoveNext
Loop
%>