eric258 Posted June 24, 2015 Share Posted June 24, 2015 i ve never used mysql this is what i would like to do on the picture there is a column tm_country HUN and an other named tm_extension at the present there is a gif representing the country hungary flag, now there are 5000 rows with HUN and i have a hard time copying and pasting the gif into each single row would you please help me with a query that would paste hassal-132.gif in each row whose contry is HUN (hungary) the name of the table as shown on the picture is ebo_sb_teams thank you for your help Quote Link to comment Share on other sites More sharing options...
Barand Posted June 24, 2015 Share Posted June 24, 2015 Don't do that. Have a "flag" table which contains records with code and image name for each country. Job done. | tm_country | image_name | +---------------+------------------+ | HUN | hassal-132.gif | When you query the first table, JOIN to the flag table using the country code Quote Link to comment Share on other sites More sharing options...
eric258 Posted June 24, 2015 Author Share Posted June 24, 2015 the table already exist, i have to populate it Quote Link to comment Share on other sites More sharing options...
eric258 Posted June 24, 2015 Author Share Posted June 24, 2015 i need in fact a query that would copy paste hassal-132.gif in all the row where the country is HUN Quote Link to comment Share on other sites More sharing options...
eric258 Posted June 24, 2015 Author Share Posted June 24, 2015 then i ll change the HUN and name of the gif for the other countries there are 254333 entries... Quote Link to comment Share on other sites More sharing options...
Barand Posted June 24, 2015 Share Posted June 24, 2015 If it exists then use it. You have the table that associates HUN with hassal132.gif, so why put "hassal_gif" into another 5000 records? You only need it the once. That is whole point of using a relational database. http://lmgtfy.com/?q=data+normalization Quote Link to comment Share on other sites More sharing options...
eric258 Posted June 24, 2015 Author Share Posted June 24, 2015 because normally i am suppose to enter a flag for every single player coming from lets say hungary but when i enter it from the back end of my site; the file changes name.... so i ve noticed that by pasting the same name on all the field i achieve the same results that is why i need a sql commande that would paste it for me and i have never seen sql commande Quote Link to comment Share on other sites More sharing options...
eric258 Posted June 24, 2015 Author Share Posted June 24, 2015 for instance one hungarian player his flag could be hassal-45.gif and an other one could be hassal-458.gif if i enter by the normal procedure but i ve noticed by pasting one hungarian flag on other hungarian row the result is the same Quote Link to comment Share on other sites More sharing options...
Barand Posted June 24, 2015 Share Posted June 24, 2015 Normalize your data. Quote Link to comment Share on other sites More sharing options...
eric258 Posted June 24, 2015 Author Share Posted June 24, 2015 (edited) it display hungarian flag on all the players so that is why i need the sql thing i ve never used sql i am not a programmer i just need a query barand could you help me with the sql file? UPDATE ebo_sb_teams SET tm_extension='hassal-132.gif' WHERE tm_country='HUN'; would this kinda line do the trick? Edited June 24, 2015 by Ch0cu3r Quote Link to comment Share on other sites More sharing options...
eric258 Posted June 24, 2015 Author Share Posted June 24, 2015 OK THX FOR YOUR HELP THIS IS WHAT I NEEDED Quote Link to comment Share on other sites More sharing options...
Barand Posted June 24, 2015 Share Posted June 24, 2015 I know I could have given you that same query at the start, but in the long run I wouldn't be doing you any favours teaching you how to build db tables that are like spreadsheets. That isn't what relational databases like mysql are for. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.