---
title: "String-SQL"
type: "forum-thread"
url: "https://www.webforum.nu/amne/asp/100649-string-sql"
topic: "ASP"
topic_url: "https://www.webforum.nu/amne/asp"
author: "Agneus"
published: "2004-03-30T19:14:08.000Z"
updated: "2004-03-30T20:07:29.000Z"
replies: 4
views: 281
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/asp/100649-string-sql"
---

# String-SQL

## #1 — Agneus, 2004-03-30T19:14Z

Hej

Vad ska jag ersätta "SAMTLIGA" med, så att alla platser listas?

```
<a href="lista.asp?plats=Åmål">Åmål</a>
<a href="lista.asp?plats=Grums">Grums</a>

<a href="lista.asp?plats=SAMTLIGA">Visa alla Platser</a>

Dim strPlats
strPlats = Request.QueryString("plats")
		
Dim strSQL
strSQL = "SELECT * FROM Tabell WHERE Plats = '" & strPlats & "' ORDER BY a,b,c asc;"
```

Permalänk: https://www.webforum.nu/p/100649

## #2 — @nders, 2004-03-30T19:29Z

```
if strPlats = "SAMTLIGA" then
     strSQL = "SELECT * FROM Tabell ORDER BY a,b,c asc;"
else
     strSQL = "SELECT * FROM Tabell WHERE Plats = '" & strPlats & "' ORDER BY a,b,c asc;"
end if
```

Permalänk: https://www.webforum.nu/p/1311944

## #3 — LarsG, 2004-03-30T19:30Z

```
Dim where
if strPlats = "SAMTLIGA" then
   where = ""
else
   where = " WHERE Plats = '" & strPlats & "'"
end if
Dim strSQL
strSQL = "SELECT * FROM Tabell " & where & "order BY a,b,c asc"
```

Permalänk: https://www.webforum.nu/p/1311945

## #4 — @nders, 2004-03-30T19:41Z

Even better, that is. :)

Permalänk: https://www.webforum.nu/p/1311950

## #5 — Agneus, 2004-03-30T20:07Z

Tack för hjälpen @nders och LarsG

Precis som jag ville att det skulle funka.

Om jag skriver så här, behöver jag tydligen inte skicka med någon parameter alls för att lista alla platserna.

```
if strPlats = "" then
```

Permalänk: https://www.webforum.nu/p/1311971

---

Tråden på webben: https://www.webforum.nu/amne/asp/100649-string-sql
