Jump to content
alexiscruz007

Remove products that have the word sex in the title

Recommended Posts

I am trying to remove all the products that have the word sex from the catalog, these are some queries.

UPDATE  `products` SET  `products_status` =  '0'
LEFT JOIN `products_description` pd ON p.products_id = pd.products_id
WHERE `products_name` LIKE '%sex%'

or

UPDATE  `products` SET  `products_status` =  '0'
INNER JOIN `products_description` ON (`products`.`products_id` = `products_description`.`products_id`)
WHERE 'products_name` LIKE '%sex%'

This logically would not work but reflects the idea of what I am looking for, if it were an ideal world.

UPDATE  `products` SET  `products_status` =  '0' WHERE  `products_description`.`products_name` LIKE '%sex%;

This query works fine.

SELECT `products_price` , `products_name`
FROM `products` p
LEFT JOIN `products_description` pd ON p.products_id = pd.products_id
WHERE `products_name` LIKE '%seeds%'
AND `products_status` =1
ORDER BY `products_name`
LIMIT 5

Thanks in advance

 

 

 

Share this post


Link to post
Share on other sites
UPDATE products p INNER JOIN products_description pd on p.products_id = pd.products_id
  SET p.products_status = 0
  WHERE pd.products_name LIKE '%sex%'

Joins before set.  You can see this in the documentation:  

UPDATE [LOW_PRIORITY] [IGNORE] table_references
    SET assignment_list
    [WHERE where_condition]

Joins are hidden inside what it is calling table_references


Always back up before making changes.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×