vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi, I'm trying to do a request but I can't figure out how to do it. Basically I have 1 table with 3 fields (field1,field2,field3). Values in those 3 fields can be the same, but I want to select all of these values only once (i.e distinct values) Example Field1 Field2 Field3 A A A B E B C F F D G H The select should return: A,B,C,D,E,F,G,H I've tried with union and a select not in but I ended up with something big and I got confused. Can someone help ? Thx |
| |||
| SELECT col1 FROM YourTable UNION SELECT col2 FROM YourTable UNION SELECT col3 FROM YourTable If that doesn't give the result you wanted then please post DDL and sample data as described here: http://www.aspfaq.com/etiquette.asp?id=5006 -- David Portas SQL Server MVP -- |