come faccio usando like o altro a cercare una o piu parole parole contenute in un campo con piu parole
codice asp
cerca = " where nomearticolo like '" & cerca & "%'order by data desc" :master:
come faccio usando like o altro a cercare una o piu parole parole contenute in un campo con piu parole
codice asp
cerca = " where nomearticolo like '" & cerca & "%'order by data desc" :master:
codice:ricerca = request.form("ricerca") voci = split(ricerca) sql = "SELECT * FROM tabella WHERE" for i = 0 to uBound(voci) sql = sql & " campo LIKE '%" & voci(i) & "%'" if i < uBound(voci) then sql = sql & " OR" next response.write sql
vedendola riga di codice mia , sostituisco poi cerca con sql no?
questo è il codice non so come modificarlo col tuo
<% dim cerca, pp
'estrazione della pagina corrente
pag=trim(request("pag"))
cerca=replace(Trim(request("cerca")),"'", "")
pp=cerca
if pag="" then pag=1
if IsEmpty(Request.querystring("cerca")) then
cerca = " where nomearticolo like '" & Request.querystring("cerca") & "%'order by data desc "
strricerca = "select * from richieste"
else
if Request.querystring("cerca")<>"" then
cerca = " where nomearticolo like '" & cerca & "%'order by data desc"
else
cerca = " where nomearticolo like '%' order by data desc"
end if
strricerca = "select * from richieste " & cerca
end if
'Response.Write strricerca
'Response.End
set rsestrai=Server.CreateObject("adodb.recordset")
rsestrai.LockType=3
rsestrai.CursorType=3
rsestrai.PageSize=5
rsestrai.ActiveConnection=connessione
rsestrai.Open strricerca
%>
guarda ho provato io e funziona , lunica cosa e che avendo per esempio campi come "lupo alberto" "lupo dario"
immettendo in cerca lupo dario mi fa comparire anche lupo alberto, cmq va bene anche cosi grazie
<%
' dim rsestrai, zona, tipologia, immobile, mq, importo
' dim strricerca, pag, i, rowcount, cerca, pp
dim cerca, pp, sql
'estrazione della pagina corrente
pag=trim(request("pag"))
cerca=replace(Trim(request("cerca")),"'", "")
pp=cerca
if pag="" then pag=1
if IsEmpty(Request.querystring("cerca")) then
cerca = " where nomearticolo like '" & Request.querystring("cerca") & "%'order by data desc "
sql = "select * from richieste"
else
if Request.querystring("cerca")<>"" then
' cerca = " where nomearticolo like '" & cerca & "%'order by data desc"
voci = split(cerca, " ")
sql = "SELECT * FROM richieste WHERE"
for i = 0 to ubound(voci)
sql = sql & " nomearticolo LIKE '%" & voci(i) & "%'"
if i < ubound(voci) then sql = sql & " OR"
next
else
cerca = " where nomearticolo like '%' order by data desc"
sql = "select * from richieste " & cerca
end if
end if
'Response.Write strricerca
'Response.End
set rsestrai=Server.CreateObject("adodb.recordset")
rsestrai.LockType=3
rsestrai.CursorType=3
rsestrai.PageSize=5
rsestrai.ActiveConnection=connessione
rsestrai.Open sql
%>
![]()
grande![]()