Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Need to change products_date_added in MySQL


wishx

Recommended Posts

Posted

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

Posted

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!

Posted

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

Posted

use the same query, adding the where clause for the categories.

Posted
use the same query, adding the where clause for the categories.

Can you give me an example? I'm pretty new at MySQL queries.

Posted

For example, would it be something like:

 

update products set products_date_added = '2004/05/15' where categories.categories_id = 37

 

?

 

WishX

Posted

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

Posted

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

Posted

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.

Posted

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

Posted

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? :)

Posted

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...