Showing posts with label SQL. Show all posts
Showing posts with label SQL. Show all posts

Monday, December 5, 2022

Update columns values with column of another table based on condition in SQL command


UPDATE table1 SET price=(SELECT price FROM table2 WHERE table1.id=table2.id);

or,
UPDATE table1 SET table1.price=(SELECT table2.price FROM table2 WHERE table2.id=table1.id AND table2.item=table1.item);

or,
UPDATE event INNER JOIN cualumni ON event.user_id = cualumni.eid SET event.user_id = cualumni.id;


Or,

UPDATE table1 INNER JOIN table2 ON table1.id = table2.id SET table1.Price = table2.price

Tuesday, April 19, 2022

Decrease product price by 10% using SQL command in Woocommernce from Phpmyadmin

 Query-1:

UPDATE

   wp_wc_product_meta_lookup

SET

    min_price =(min_price - min_price * .13)

WHERE 1;

Query-2;

 UPDATE

   wp_wc_product_meta_lookup

SET

    max_price =(max_price - max_price * .13)

WHERE 1;

Friday, March 11, 2022

How to Delete All Products in WooCommerce using SQL Command?

  1. Log in to the phpMyAdmin portal
  2. Select the database that has all the products to be deleted. Make sure, that you backup your database before executing the SQL statement!
  3. Than select table {prefix}_posts and run the SQL statement as shown.


DELETE relations.*, taxes.*, terms.*

FROM metro4u_term_relationships AS relations

INNER JOIN metro4u_term_taxonomy AS taxes

ON relations.term_taxonomy_id=taxes.term_taxonomy_id

INNER JOIN metro4u_terms AS terms

ON taxes.term_id=terms.term_id

WHERE object_id IN (SELECT ID FROM metro4u_posts WHERE post_type IN ('product','product_variation'));


DELETE FROM metro4u_postmeta WHERE post_id IN (SELECT ID FROM metro4u_posts WHERE post_type IN ('product','product_variation'));

DELETE FROM metro4u_posts WHERE post_type IN ('product','product_variation');


Note: "metro4u" is a prefix. Set your Database Table prefix

Sunday, December 8, 2019

How to concatenate self column in mysql

By using the following sql command we can edit a column with the value of same column: UPDATE tblclients SET phonenumber = concat('880',RIGHT(phonenumber,10)); 

How to get Ranking of the Students in Excel using RANK Function

=RANK(number,ref,[order]) To rank in descending order, we will use the formula =RANK(B2,($C$5:$C$10),0) If we want unique ranks, we can use...