1

I have a travel log, I am trying to display a list of cities visited during a day

 id  day cityvisited user
  1   1        2        4  
  1   1        6        3
  1   1        4        10
  1   1        4        6

SELECT cityvisited FROM cv WHERE day = 1 

returns the data 2, 6, 4, 4

Can I get it so it just returns 2, 6, 4

user934902
  • 1,184
  • 3
  • 15
  • 33
  • possible duplicate of [How to select unique records by SQL](http://stackoverflow.com/questions/1641718/how-to-select-unique-records-by-sql) – FuzzyTree Jun 15 '14 at 01:16

3 Answers3

4
SELECT DISTINCT cityvisited FROM cv WHERE day = 1

should do it.

VBlades
  • 2,241
  • 1
  • 12
  • 8
0

Which SQL you are using ?

If you are using SQL Server then you can use

 SELECT distinct cityvisited FROM cv WHERE day = 1

It works for many other DB as well.

Hope this help you.

dotnetstep
  • 17,065
  • 5
  • 54
  • 72
0

Select distinct cityvisited from cv where day = 1

will work in tsql.

if your using a different type of sql and distinct doesnt work you could just add group by cityvisited to your query

Dannyg9090
  • 196
  • 8