Information générale
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Select one or the other
Hi All,
I'm trying to build a Select, but I can't get it to do what I want. This is the situation:
There's one table with three fields:
Field1 Field2 Field3
0 X A
0 Y B
0 Z C
1 X D
1 Y E
1 Z F
2 X G
2 Z H
I want to select field3 of every occurrence of field2 (X,Y and Z) where field1 is a certain value and if it doesn't exist the field3 of field1=0 should be selected. If I want this for field1=1 this would result in:
D
E
F
And if this is done for field1=2 it would result in
G
B (this one is of field1=0)
H
Who can do this the easiest way?
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement