SQL Syntax Help

Started by mhulak on 20 Aug 2012, 1:22 AM · Views: 1,086

Results 1 to 9 of 9
20 Aug 2012, 1:22 AM
#1
mhulak avatar

mhulak

New Zenner

Join Date:
Feb 2012
Posts:
78
Plugin Contributions:
0

SQL Syntax Help

I would like to set the values of all items in master category 1 for metatags_model_status to all = 0

I have some other values I want changed as well. But this information should get me started.

I tried some variations of the below syntax without success
SELECT * FROM znc_products WHERE master_categories_id = 1
SET metatags_model_status = replace(metatags_model_status,'1','0');

Further to this, I would like to update all the meta keywords and such for all items in master category 1

Yes, I have backed up my DB

20 Aug 2012, 1:31 AM
#2
limitless avatar

limitless

Inactive

Join Date:
Jan 2012
Posts:
496
Plugin Contributions:
0

Re: SQL Syntax Help

Should be something like:

UPDATE products
SET metatags_model_status = 0
WHERE master_categories_id = 1

20 Aug 2012, 2:03 AM
#3
mhulak avatar

mhulak

New Zenner

Join Date:
Feb 2012
Posts:
78
Plugin Contributions:
0

Re: SQL Syntax Help

this worked using

UPDATE znc_products
SET metatags_title_tagline_status = 0
WHERE master_categories_id = 1

THX...

One more thing. How would I change the meta keywords, description for all those in that master category? I am not able to find a way to connected the 2 tables with the product meta information with the products to category table

I guess something like
SELECT * FROM znc_meta_tags_products_description , znc_products WHERE master_categories_id = 1

20 Aug 2012, 2:10 AM
#4
limitless avatar

limitless

Inactive

Join Date:
Jan 2012
Posts:
496
Plugin Contributions:
0

Re: SQL Syntax Help

I think you are looking for a join to return the data you need.

Sorry, I'm more of a hack with SQL than anything.

28 Aug 2012, 1:43 PM
#5
mhulak avatar

mhulak

New Zenner

Join Date:
Feb 2012
Posts:
78
Plugin Contributions:
0

Re: SQL Syntax Help

BUMP>>

I am unable to figure out how to update the title, meta keyword and meta description for all the items in a specific category.

Can someone show me how to change that information only for a specific category?

28 Aug 2012, 2:00 PM
#6
mhulak avatar

mhulak

New Zenner

Join Date:
Feb 2012
Posts:
78
Plugin Contributions:
0

Re: SQL Syntax Help

i see products are linked using a specific table

SELECT *
FROM znc_products_to_categories
WHERE 1
LIMIT 0 , 30

if i want to call up the meta information for all products i use the following

SELECT *
FROM znc_meta_tags_products_description
WHERE 1
LIMIT 0 , 30

i need help on syntax to select the meta_tag_ information for all products in a specific category

tyia

28 Aug 2012, 3:19 PM
#7
limitless avatar

limitless

Inactive

Join Date:
Jan 2012
Posts:
496
Plugin Contributions:
0

Re: SQL Syntax Help

Adjust for your db/table names:

Select *
From products_to_categories Inner Join
meta_tags_products_description On meta_tags_products_description.products_id =
products_to_categories.products_id
WHERE 1
LIMIT 0, 30

28 Aug 2012, 9:15 PM
#8
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,880
Plugin Contributions:
7

Re: SQL Syntax Help

why don't you just export the products and the field you want to change using Apsona to a CSV, edit it and import it back, no need to risk sql mistakes?

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...

29 Aug 2012, 5:49 AM
#9
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: SQL Syntax Help

torvista:

why don't you just export the products and the field you want to change using Apsona to a CSV, edit it and import it back, no need to risk sql mistakes?

Speed!

A few minutes spent learning how to achieve a bulk change using SQL can save many hours of export/edit/import, which also has its own risk of mistakes. The important thing is avoid doing the learning on 'live' data. Make a copy first.

Cheers
Rod

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.