måske noget i den her stil. Det er totalt utestet og bare en ide til hvordan du kan opbygge din sql.
navn = request.form("search") tabel = split(navn," ")
for x=0 to ubound(tabel) strSQL = strSQL & " OR (fornavn LIKE '%" & tabel(x) & "%')" strSQL = strSQL & " OR (efternavn LIKE '%" & tabel(x) & "%')" next strSQL = strSQL & " order by fornavn"
strSQL = "SELECT etternavn, fornavn, mob, privat, adresse, epost, id FROM telefon WHERE "
for x=0 to ubound(tabel) if x=0 then strSQL = strSQL & " (fornavn LIKE '%" & tabel(x) & "%') OR (efternavn LIKE '%" & tabel(x) & "%') " else strSQL = strSQL & " (or fornavn LIKE '%" & tabel(x) & "%') OR (efternavn LIKE '%" & tabel(x) & "%')" end if next strSQL = strSQL & " order by fornavn" %>
strSQL = "SELECT etternavn, fornavn, mob, privat, adresse, epost, id FROM telefon WHERE "
for x=0 to ubound(tabel) if x=0 then strSQL = strSQL & " (fornavn LIKE '%" & tabel(x) & "%') OR (efternavn LIKE '%" & tabel(x) & "%') " else strSQL = strSQL & " (or fornavn LIKE '%" & tabel(x) & "%') OR (efternavn LIKE '%" & tabel(x) & "%')" end if next strSQL = strSQL & " order by fornavn"
strSQL = "SELECT etternavn, fornavn, mob, privat, adresse, epost, id FROM telefon WHERE "
for x=0 to ubound(tabel) if x=0 then strSQL = strSQL & " (fornavn LIKE '%" & tabel(x) & "%') OR (efternavn LIKE '%" & tabel(x) & "%') " else strSQL = strSQL & " or (fornavn LIKE '%" & tabel(x) & "%') OR (efternavn LIKE '%" & tabel(x) & "%')" end if next strSQL = strSQL & " order by fornavn"
SELECT etternavn, fornavn, mob, privat, adresse, epost, id FROM telefon WHERE (fornavn LIKE '%tormod%') OR (etternavn LIKE '%tormod%') or (fornavn LIKE '%almås%') OR (etternavn LIKE '%almås%') order by fornavn
Problemet er at når jeg søker på feks. "Tormod Almås" så kommer det opp alle navn som har "almås" som efternavn. Jeg vil at når jeg søker på "tormod almås" så skal kun det ene navnet komme opp.
strSQL = "SELECT etternavn, fornavn, mob, privat, adresse, epost, id FROM telefon WHERE "
for x=0 to ubound(tabel) if x=0 then strSQL = strSQL & " (fornavn LIKE '%" & tabel(x) & "%') " else strSQL = strSQL & " or (efternavn LIKE '%" & tabel(x) & "%')" end if next strSQL = strSQL & " order by fornavn"
strSQL = "SELECT etternavn, fornavn, mob, privat, adresse, epost, id FROM telefon WHERE "
for x=0 to ubound(tabel) if x=0 then strSQL = strSQL & " (fornavn LIKE '%" & tabel(x) & "%') " else strSQL = strSQL & " and (efternavn LIKE '%" & tabel(x) & "%')" end if next strSQL = strSQL & " order by fornavn"
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.