Mysql query syntax and examples

From Wiki at Neela Nurseries
Revision as of 19:29, 28 August 2017 by Ted (talk | contribs) (2017-08-28 MON - Ted starting MYSQL query syntax and example notes, on Neela Nurseries wiki.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

MYSQL Query Syntax And Examples
notes started 2017-08-28
by Ted Havelka


OVERVIEW

EXAMPLES

MYSQL's IN clause, useful to combine OR statements in queries and useful to express subqueries. Example:



    mysql> update oc_product as t1 set t1.status = 0 where t1.product_id in (select t2.product_id from oc_product_to_category as t2 where t2.category_id = 60);
    Query OK, 18 rows affected (0.00 sec)
    Rows matched: 18  Changed: 18  Warnings: 0

    mysql> update oc_product as t1 set t1.status = 0 where t1.product_id in (select t2.product_id from oc_product_to_category as t2 where t2.category_id = 64);
    Query OK, 6 rows affected (0.00 sec)
    Rows matched: 6  Changed: 6  Warnings: 0

mysql>