/*
mysql> select * from Product;
+-----------+------------+--------------------+-----------------------+
| ProductID | Name | OnCatalogPromotion | Description |
+-----------+------------+--------------------+-----------------------+
| 1 | Java | 0 | Java Demo Code! |
| 2 | C# | 1 | C# Demo Code! |
| 3 | JavaScript | 1 | JavaScript Demo Code! |
+-----------+------------+--------------------+-----------------------+
3 rows in set (0.00 sec)
mysql> /* Getting the List of Products That Are on Catalog Promotion */
mysql> SELECT Name, Description FROM Product
-> WHERE OnCatalogPromotion=1
-> ORDER BY Name;
+------------+-----------------------+
| Name | Description |
+------------+-----------------------+
| C# | C# Demo Code! |
| JavaScript | JavaScript Demo Code! |
+------------+-----------------------+
2 rows in set (0.00 sec)
*/
/* Create Database */
Drop TABLE Product;
CREATE TABLE Product (
ProductID INT AUTO_INCREMENT NOT NULL PRIMARY KEY,
Name VARCHAR(50) NOT NULL,
OnCatalogPromotion BIT NULL,
Description VARCHAR(255) NOT NULL
) Type=InnoDB;
/* Add data */
INSERT INTO Product (Name, OnCatalogPromotion, Description) VALUES ('Java', 0,
'Java Demo Code!' );
INSERT INTO Product (Name, OnCatalogPromotion, Description) VALUES ('C#', 1,
'C# Demo Code!' );
INSERT INTO Product (Name, OnCatalogPromotion, Description) VALUES ('JavaScript',
1, 'JavaScript Demo Code!' );
select * from Product;
/* Getting the List of Products That Are on Catalog Promotion */
SELECT Name, Description FROM Product
WHERE OnCatalogPromotion=1
ORDER BY Name;
|