dimanche 1 mars 2015

Updating MySql Column based on another Column

Hey guys I am still pretty new to MySQL and I just ran into a problem that I can't seem to figure out.


Say I have a table called "tracks" with the following columns and sample data



track_hash | track_order
abc | 1
abc | 2
abc | 3
abc | 4
def | 1
def | 2
ghi | 1


So the point is that when I display the tracks, the tracks should be ordered by the track order. So if i want to display all tracks from abc, it will display it based on the track order (1, 2, 3). Track hash "def" has two tracks...etc.


So currently in my DB I just have an empty track_order column. How would I go about to filling the track_order column with the correct data?





Aucun commentaire:

Enregistrer un commentaire