shage Posted June 10, 2008 Share Posted June 10, 2008 I have a database that is forever old that was one of the first things i ever did, the db has close to 5k records in it, is there a way to pull only say every record that ends in 1 or 2 for the id, such as 101 and 1001, the way the db is set up every 1 is shoes, every 2 is tvs, every 3 is toys etc, but they have no cats so looking to add a cat to them buy running a query and adding all 3's are in cat toys, thank you Quote Link to comment Share on other sites More sharing options...
luca200 Posted June 10, 2008 Share Posted June 10, 2008 UPDATE table SET cat = 'shoes' WHERE id % 10 = 1 UPDATE table SET cat = 'tvs' WHERE id % 10 = 2 UPDATE table SET cat = 'toys' WHERE id % 10 = 3 Quote Link to comment Share on other sites More sharing options...
fenway Posted June 10, 2008 Share Posted June 10, 2008 Or you could use a CASE statement and issue a single udpate: UPDATE table SET cat = CASE id % 10 WHEN 1 THEN 'shoes' WHEN 2 THEN 'tvs' WHEN 3 THEN 'toys' ELSE cat END 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.