PDA

View Full Version : Problems with a curious MySQL query


seavolvox
08-09-2005, 12:18 PM
Hi,

I'm having some troubles trying to set a mysql query...

Imagine you have a table with three columns and their values:

Column1 / Column2 / Column3
1 / Barcelona / A
2 / Madrid / B
3 / Zaragoza / C
4 / Barcelona / D
5 / Barcelona / E
6 / Madrid / C
7 / Barcelona / A
8 / Barcelona / A

I'd like to get values A (ONLY ONCE, not 3 As), D and E.

I've tried to use SELECT DISTINCT but no luck.
The idea is to get all "DISCTINCT" values from Column3 BUT only where Column2 is "Barcelona".

Thank you in advance for your help!

Oups! I'm using PHP!

e-Raser
08-09-2005, 12:24 PM
This is a guess but
SELECT DISTINCT column3 FROM table WHERE column2='Barcelona'
?

seavolvox
08-10-2005, 01:54 PM
Thank you!!