---
title: "Fel när tabellen är tom"
type: "forum-thread"
url: "https://www.webforum.nu/amne/databaser-sql/54039-fel-när-tabellen-är-tom"
topic: "Databaser & SQL"
topic_url: "https://www.webforum.nu/amne/databaser-sql"
author: "NETwork"
published: "2002-09-23T10:41:19.000Z"
updated: "2002-09-23T12:21:26.000Z"
replies: 1
views: 170
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/databaser-sql/54039-fel-när-tabellen-är-tom"
---

# Fel när tabellen är tom

## #1 — NETwork, 2002-09-23T10:41Z

Jag har två tabeller där jag plockar fram alla användare från tabell 1 (distinct) som inte redan finns i tabell 2.

SELECT DISTINCT tabell1.user FROM tabell1 INNER JOIN tabell2 ON tabell1.user \<\> tabell2.user

Detta fungerar utmärkt, UTOM när tabell 2 är tom, då hämtar den inget alls (jag vill då att den ska hämta alla). Hur löser jag detta på ett bra sätt!?

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

## #2 — LarsG, 2002-09-23T12:21Z

```
SELECT DISTINCT tabell1.user 
FROM tabell1 left JOIN tabell2 
ON tabell1.user = tabell2.user
where tabell2.user is null
```

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

---

Tråden på webben: https://www.webforum.nu/amne/databaser-sql/54039-fel-när-tabellen-är-tom
