wishx Posted June 30, 2004 Posted June 30, 2004 Howdy, I need to change all the current products in my database to 2004-05-15 00:00:00. I know the default before a product is added is 0000-00-00 00:00:00, but I don't want to change the default. I need to alter every product that is currently in there. Does any know a quick UPDATE query I can pop into phpMyAdmin and change everything in products_date_added? Thanks in advance! WishX
OceanRanch Posted June 30, 2004 Posted June 30, 2004 update products set products_date_added = '05/15/2004' HTH Tom
wishx Posted June 30, 2004 Author Posted June 30, 2004 I just ran that and everything in products_date_added is coming up as: 0000-00-00 00:00:00 That didn't do the trick. Any other ideas? WishX Edit: Should have been update products set products_date_added = '2004/05/15' That worked. Thanks again!
wishx Posted June 30, 2004 Author Posted June 30, 2004 Now I have a more refined question about the same thing... How would I change the products_date_added for all products in a specific category? Example: Books -->Horror ---->Book 1 ---->Book 2 ---->Book 3 -->Sci Fi ---->Sci Book 1 ---->Sci Book 2 ---->Sci Book 3 Let's say I want all the "Books" to appear to be added 05/15/2004, but I want all "Sci Books" to appear to be added 06/30/2004. What query would I use to make that happen? Thanks again! WishX
Guest Posted June 30, 2004 Posted June 30, 2004 use the same query, adding the where clause for the categories.
wishx Posted June 30, 2004 Author Posted June 30, 2004 use the same query, adding the where clause for the categories. Can you give me an example? I'm pretty new at MySQL queries.
wishx Posted June 30, 2004 Author Posted June 30, 2004 For example, would it be something like: update products set products_date_added = '2004/05/15' where categories.categories_id = 37 ? WishX
OceanRanch Posted June 30, 2004 Posted June 30, 2004 update products set products_date_added = '2004/05/15' from products, products_to_categories where products_to_categories.categories_id = 37 and products.products_id = products_to_categories.products_id HTH and hope it works....;) Tom
wishx Posted June 30, 2004 Author Posted June 30, 2004 HTH and hope it works....;) Tom So what you're saying is make a backup first? ;)
OceanRanch Posted June 30, 2004 Posted June 30, 2004 Always have a fall back scenario...if things fail.
wishx Posted June 30, 2004 Author Posted June 30, 2004 Didn't work. I got this: Error SQL-query : update products set products_date_added = '2004/06/01' from products, products_to_categories where products_to_categories.categories_id = 32 and products.products_id = products_to_categories.products_id MySQL said: You have an error in your SQL syntax near 'from products, products_to_categories where products_to_categories.categories_i' at line 2
OceanRanch Posted June 30, 2004 Posted June 30, 2004 Try update products, products_to_categories set products_date_added = '2004/06/01' where products_to_categories.categories_id = 32 and products.products_id = products_to_categories.products_id Previous syntax works well in SQL2000 and Sybase.
wishx Posted June 30, 2004 Author Posted June 30, 2004 Still no good. Got this: Error SQL-query : update products, products_to_categories set products_date_added = '2004/06/01' where products_to_categories.categories_id = 32 and products.products_id = products_to_categories.products_id MySQL said: You have an error in your SQL syntax near ' products_to_categories set products_date_added = '2004/06/01' where products_t' at line 1
wishx Posted July 1, 2004 Author Posted July 1, 2004 I still can't seem to come up with the right query. It seems easier than it is to me. Can I get a little help from a MySQL expert please? :)
wishx Posted July 1, 2004 Author Posted July 1, 2004 Did I happen to mention this is for a client with a live store and I've been trying to figure this out for 2 days now? ANY help would be greatly appreciated. Thanks
Recommended Posts
Archived
This topic is now archived and is closed to further replies.