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
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
+ 6
You can practice sql in sql code playground!
https://code.sololearn.com/WeL61aj0O35B/?ref=app
+ 2
https://www.sololearn.com/learn/SQL/1853/
+ 2
Thank you guys it works