0

SQl question

Hi I have this tabble Id cityName customer 1. Madrid. David 1. Madrid. Silva 1. Madrid. Mariya 2. Istanbul. Adi 3. Rome. Dina 3. Rome. Pedro 3. Rome. Dani 3. Rome. Indira 4. Chicago. Sally 4. Chicago. Ashtone But i want to have this Id cityName 1. Madrid 2. Istanbul 3. Rome 4. Chicago

29th Apr 2020, 6:14 AM
Hamed Niazmand
Hamed Niazmand - avatar
4 Respostas
+ 5
Hamed Niazmand For this specific scenario where the first dataset in your question is from a single table, you would use the DISTINCT keyword on the two columns for the dataset format you are targeting. -------- SELECT DISTINCT Id, cityName FROM dataset; -------- I've put together a tutorial like script on an online editor for MySQL to provide some other insight on this question. Try to follow my comments as seen in both the SQL script, as well as in the output results. I hope these make sense. -------- Link to MySQL Editor Script: ---- https://paiza.io/projects/BXh9_oBrmPEOtJYbry_Ecw -------- Link to MySQL Results Page: ---- https://out.paiza.io/projects/BXh9_oBrmPEOtJYbry_Ecw/output.txt
30th Apr 2020, 5:42 AM
David Carroll
David Carroll - avatar
+ 6
You can practice sql in sql code playground! https://code.sololearn.com/WeL61aj0O35B/?ref=app
30th Apr 2020, 5:47 AM
r8w9
r8w9 - avatar
+ 2
https://www.sololearn.com/learn/SQL/1853/
29th Apr 2020, 7:42 AM
dozule
dozule - avatar
+ 2
Thank you guys it works
30th Apr 2020, 1:43 PM
Hamed Niazmand
Hamed Niazmand - avatar