0% found this document useful (0 votes)
22 views

New 2

The document details steps to set up XAMPP and MariaDB on a Windows system. It creates a 'product_details' database and table, inserts sample data, and attempts various queries with syntax errors to learn SQL.

Uploaded by

kaxej12575
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

New 2

The document details steps to set up XAMPP and MariaDB on a Windows system. It creates a 'product_details' database and table, inserts sample data, and attempts various queries with syntax errors to learn SQL.

Uploaded by

kaxej12575
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

Setting environment for using XAMPP for Windows.

student@PC14 c:\xampp
# cd mysql/bin

student@PC14 c:\xampp\mysql\bin
# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.1.34-MariaDB mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database product_details;


ERROR 1007 (HY000): Can't create database 'product_details'; database exists
MariaDB [(none)]> drop database product_details;
Query OK, 0 rows affected (0.04 sec)

MariaDB [(none)]> show databases;


+--------------------+
| Database |
+--------------------+
| car |
| dmart |
| hardik |
| information_schema |
| mayur |
| mysql |
| performance_schema |
| phpmyadmin |
| pmart |
| rohan |
| sports |
| test |
| vaibhavi |
+--------------------+
13 rows in set (0.00 sec)

MariaDB [(none)]> create database product_details;


Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> use product_details;


Database changed
MariaDB [product_details]> create table product_details (
-> product_id varchar(06) primary key,
-> product_name varchar(10),
-> category varchar(20),
-> price int(03),
-> quality varchar(30) );
Query OK, 0 rows affected (0.28 sec)

MariaDB [product_details]> describe product_details;


+--------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------+-------------+------+-----+---------+-------+
| product_id | varchar(6) | NO | PRI | NULL | |
| product_name | varchar(10) | YES | | NULL | |
| category | varchar(20) | YES | | NULL | |
| price | int(3) | YES | | NULL | |
| quality | varchar(30) | YES | | NULL | |
+--------------+-------------+------+-----+---------+-------+
5 rows in set (0.01 sec)

MariaDB [product_details]> alter table product_details


-> address varchar(30) );
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to use near
'varchar(30) )' at line 2
MariaDB [product_details]> alter table product_details;
Query OK, 0 rows affected (0.00 sec)
Records: 0 Duplicates: 0 Warnings: 0

MariaDB [product_details]> alter table product_details


-> address varchar(30);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to use near
'varchar(30)' at line 2
MariaDB [product_details]> alter table product_details
-> address varchar(20);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to use near
'varchar(20)' at line 2
MariaDB [product_details]> alter table product_details (
-> address varchar(20) );
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to use near '(
address varchar(20) )' at line 1
MariaDB [product_details]> alter table product_details
-> sr_no int(02);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to use near
'int(02)' at line 2
MariaDB [product_details]> insert into product_details
-> (product_id,product_name,category,price,quality)values
-> ('234560','toy','plastic',149,'best'),
-> ('238956','water bottle','plastic',50,'best'),
-> ('237890','shampoo','liquvid',75,'high'),
-> ('236678','lunchbox','plastic',80,'best'),
-> ('234562','book','page',120,'best');
Query OK, 5 rows affected, 1 warning (0.05 sec)
Records: 5 Duplicates: 0 Warnings: 1

MariaDB [product_details]> select*from product_details;


+------------+--------------+----------+-------+---------+
| product_id | product_name | category | price | quality |
+------------+--------------+----------+-------+---------+
| 234560 | toy | plastic | 149 | best |
| 234562 | book | page | 120 | best |
| 236678 | lunchbox | plastic | 80 | best |
| 237890 | shampoo | liquvid | 75 | high |
| 238956 | water bott | plastic | 50 | best |
+------------+--------------+----------+-------+---------+
5 rows in set (0.00 sec)

MariaDB [product_details]> update product_details set product_name where product_id


=238956;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to use near 'where
product_id =238956' at line 1
MariaDB [product_details]> update product_details set product_name
whereproduct_id=238956;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to use near
'whereproduct_id=238956' at line 1
MariaDB [product_details]> update product_details set (product_name) where
(product_id=238956);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to use near
'(product_name) where (product_id=238956)' at line 1
MariaDB [product_details]> update product_details set product_name where
product_id='238956';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to use near 'where
product_id='238956'' at line 1
MariaDB [product_details]> update product_details set product_name where
product_id238956;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to use near 'where
product_id238956' at line 1
MariaDB [product_details]> update product_details set product_name where from
product_id='238956';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to use near 'where
from product_id='238956'' at line 1
MariaDB [product_details]> update product_details set
product_namewhereproduct_id=238956;
ERROR 1054 (42S22): Unknown column 'product_namewhereproduct_id' in 'field list'
MariaDB [product_details]> update product_details set product_name where price=50;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to use near 'where
price=50' at line 1
MariaDB [product_details]> slect*from product_details;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to use near
'slect*from product_details' at line 1
MariaDB [product_details]> select*from product_details;
+------------+--------------+----------+-------+---------+
| product_id | product_name | category | price | quality |
+------------+--------------+----------+-------+---------+
| 234560 | toy | plastic | 149 | best |
| 234562 | book | page | 120 | best |
| 236678 | lunchbox | plastic | 80 | best |
| 237890 | shampoo | liquvid | 75 | high |
| 238956 | water bott | plastic | 50 | best |
+------------+--------------+----------+-------+---------+
5 rows in set (0.00 sec)

MariaDB [product_details]> select*from count(category)as product_details;


ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to use near
'count(category)as product_details' at line 1
MariaDB [product_details]> select*from count(category) product_details;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to use near
'count(category) product_details' at line 1
MariaDB [product_details]> select count(category)as product_details;
ERROR 1054 (42S22): Unknown column 'category' in 'field list'
MariaDB [product_details]> select count(product_category) product_details;
ERROR 1054 (42S22): Unknown column 'product_category' in 'field list'
MariaDB [product_details]> select count(product_name) product_details;
ERROR 1054 (42S22): Unknown column 'product_name' in 'field list'
MariaDB [product_details]> select max(product_details);
ERROR 1054 (42S22): Unknown column 'product_details' in 'field list'
MariaDB [product_details]> select sum(category);
ERROR 1054 (42S22): Unknown column 'category' in 'field list'
MariaDB [product_details]> select*from sum(price);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to use near
'sum(price)' at line 1
MariaDB [product_details]> select sum(price);
ERROR 1054 (42S22): Unknown column 'price' in 'field list'
MariaDB [product_details]> select*from sum(price);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to use near
'sum(price)' at line 1
MariaDB [product_details]> select*from total sum(price);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to use near
'sum(price)' at line 1
MariaDB [product_details]> select*from product_details;
+------------+--------------+----------+-------+---------+
| product_id | product_name | category | price | quality |
+------------+--------------+----------+-------+---------+
| 234560 | toy | plastic | 149 | best |
| 234562 | book | page | 120 | best |
| 236678 | lunchbox | plastic | 80 | best |
| 237890 | shampoo | liquvid | 75 | high |
| 238956 | water bott | plastic | 50 | best |
+------------+--------------+----------+-------+---------+
5 rows in set (0.00 sec)

You might also like