Lab2A phpmyadmin on mySql



#1 Start Wamp or XAMPP Server


 #2 Goto the Chrome  browser  type localhost
click phpmyadmin
Logon



Type root and leave blank for password








#3
Create database example

Type MyDatabase  and click create as shown below:



#4 Create Table products example

 CREATE TABLE IF NOT EXISTS `products` (
  `pid` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(100) NOT NULL,
  `price` decimal(10,2) NOT NULL,
  `description` text,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`pid`)
)


Click on SQL Tab, type the SQL statement as shown below and click Go as shown below



If no error in the SQL statement you would see a table 'products' created as shown below:


Click on Structure Tab and you will see the Table Structures
like the fields :

pid  (Primary Key and AUTO_INCREMENT)
name :  varchar(100)
price :   decimal(10,2)
description : text



#5 Insert values to the products table


INSERT INTO `products` ( `name`, `price`, `description`, `created_at`, `updated_at`) 
VALUES ( 'Long-grain rice, not parboiled, WKB', '3.00', '1000g', '2018-09-05 08:53:46', NULL);






#6 Insert more values to the products table

INSERT INTO `products` (`name`, `price`, `description`, `created_at`, `updated_at`) VALUES
('Long-grain rice, not parboiled, BL', '4.00', '1000g', '2018-09-05 08:53:46', NULL),
('Long-grain rice, parboiled, in cooking bags, WKB', '5.00', '1000g', '2018-09-05 08:53:46', NULL);



#7 Try other SQL statements like 

Do the following one at a time and observe its output


SELECT * FROM `products`
SELECT  `name`,`price` from products
 SELECT * FROM `products` WHERE pid ='1'
SELECT * FROM `products` WHERE name like '%not parboiled%'
DELETE FROM `products` WHERE pid ='2'
UPDATE `products` SET  `price`= '3.80' WHERE `pid` = '3'

No comments:

Post a Comment

Note: only a member of this blog may post a comment.