SHARE
TWEET

Untitled

a guest Jul 19th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. create table sales(
  2.     -> SalesID int not null,
  3.     -> OrderDescription varchar(100) not null,
  4.     -> Quantity int not null,
  5.     -> Price int not null,
  6.     -> ItemDescription varchar(100),
  7.     -> primary key(SalesID));
  8. Query OK, 0 rows affected (0.24 sec)
  9.  
  10. MariaDB [sales]> describe sales;
  11. +------------------+--------------+------+-----+---------+-------+
  12. | Field            | Type         | Null | Key | Default | Extra |
  13. +------------------+--------------+------+-----+---------+-------+
  14. | SalesID          | int(11)      | NO   | PRI | NULL    |       |
  15. | OrderDescription | varchar(100) | NO   |     | NULL    |       |
  16. | Quantity         | int(11)      | NO   |     | NULL    |       |
  17. | Price            | int(11)      | NO   |     | NULL    |       |
  18. | ItemDescription  | varchar(100) | YES  |     | NULL    |       |
  19. +------------------+--------------+------+-----+---------+-------+
  20. 5 rows in set (0.04 sec)
  21.  
  22. MariaDB [sales]> insert into sales values(100,"Frock",20,1200,"New with tag"),(200,"Trouser",15,1850,"");
  23. Query OK, 2 rows affected (0.14 sec)
  24. Records: 2  Duplicates: 0  Warnings: 0
  25.  
  26. MariaDB [sales]> insert into sales values(300,"T-Shirts",30,1300,"New with tag"),(400,"Shirts",25,2000,"");
  27. Query OK, 2 rows affected (0.14 sec)
  28. Records: 2  Duplicates: 0  Warnings: 0
  29.  
  30. MariaDB [sales]> select * from sales;
  31. +---------+------------------+----------+-------+-----------------+
  32. | SalesID | OrderDescription | Quantity | Price | ItemDescription |
  33. +---------+------------------+----------+-------+-----------------+
  34. |     100 | Frock            |       20 |  1200 | New with tag    |
  35. |     200 | Trouser          |       15 |  1850 |                 |
  36. |     300 | T-Shirts         |       30 |  1300 | New with tag    |
  37. |     400 | Shirts           |       25 |  2000 |                 |
  38. +---------+------------------+----------+-------+-----------------+
  39. 4 rows in set (0.00 sec)
  40.  
  41. MariaDB [sales]> select SalesID,OrderDescription from sales;
  42. +---------+------------------+
  43. | SalesID | OrderDescription |
  44. +---------+------------------+
  45. |     100 | Frock            |
  46. |     200 | Trouser          |
  47. |     300 | T-Shirts         |
  48. |     400 | Shirts           |
  49. +---------+------------------+
  50. 4 rows in set (0.00 sec)
  51.  
  52. MariaDB [sales]> select * from sales where salesid=200
  53.     -> ;
  54. +---------+------------------+----------+-------+-----------------+
  55. | SalesID | OrderDescription | Quantity | Price | ItemDescription |
  56. +---------+------------------+----------+-------+-----------------+
  57. |     200 | Trouser          |       15 |  1850 |                 |
  58. +---------+------------------+----------+-------+-----------------+
  59. 1 row in set (0.07 sec)
  60.  
  61. MariaDB [sales]> select orderdescription from sales where salesid=200;
  62. +------------------+
  63. | orderdescription |
  64. +------------------+
  65. | Trouser          |
  66. +------------------+
  67. 1 row in set (0.00 sec)
  68.  
  69. MariaDB [sales]> SELECT price*1.1 FROM sales;
  70. +-----------+
  71. | price*1.1 |
  72. +-----------+
  73. |    1320.0 |
  74. |    2035.0 |
  75. |    1430.0 |
  76. |    2200.0 |
  77. +-----------+
  78. 4 rows in set (0.00 sec)
  79.  
  80. MariaDB [sales]> SELECT price*1.1 as NewPrice FROM sales;
  81. +----------+
  82. | NewPrice |
  83. +----------+
  84. |   1320.0 |
  85. |   2035.0 |
  86. |   1430.0 |
  87. |   2200.0 |
  88. +----------+
  89. 4 rows in set (0.00 sec)
  90.  
  91. MariaDB [sales]> select salesid from sales where price < 1500;
  92. +---------+
  93. | salesid |
  94. +---------+
  95. |     100 |
  96. |     300 |
  97. +---------+
  98. 2 rows in set (0.00 sec)
  99.  
  100. MariaDB [sales]> select orderdescription from sales where price > 1500 and price < 2000;
  101. +------------------+
  102. | orderdescription |
  103. +------------------+
  104. | Trouser          |
  105. +------------------+
  106. 1 row in set (0.00 sec)
  107.  
  108. MariaDB [sales]> select * from sales where
  109.     -> orderdescription not like 'Frock'
  110.     -> and orderdescription not like 'Trouser'
  111.     -> and orderdescription not like 'T-Shirts'
  112.     -> and orderdescription not like 'Shirts';
  113. Empty set (0.00 sec)
  114.  
  115. MariaDB [sales]> select orderdescription from sales where price > 1500 or quantity < 15;
  116. +------------------+
  117. | orderdescription |
  118. +------------------+
  119. | Trouser          |
  120. | Shirts           |
  121. +------------------+
  122. 2 rows in set (0.00 sec)
  123.  
  124. MariaDB [sales]> select orderdescription from sales where price > 1500 or quantity > 20;
  125. +------------------+
  126. | orderdescription |
  127. +------------------+
  128. | Trouser          |
  129. | T-Shirts         |
  130. | Shirts           |
  131. +------------------+
  132. 3 rows in set (0.00 sec)
  133.  
  134. MariaDB [sales]> select orderdescription from sales where price != 1500;
  135. +------------------+
  136. | orderdescription |
  137. +------------------+
  138. | Frock            |
  139. | Trouser          |
  140. | T-Shirts         |
  141. | Shirts           |
  142. +------------------+
  143. 4 rows in set (0.00 sec)
  144.  
  145. MariaDB [sales]> select * from sales order by price DESC;
  146. +---------+------------------+----------+-------+-----------------+
  147. | SalesID | OrderDescription | Quantity | Price | ItemDescription |
  148. +---------+------------------+----------+-------+-----------------+
  149. |     400 | Shirts           |       25 |  2000 |                 |
  150. |     200 | Trouser          |       15 |  1850 |                 |
  151. |     300 | T-Shirts         |       30 |  1300 | New with tag    |
  152. |     100 | Frock            |       20 |  1200 | New with tag    |
  153. +---------+------------------+----------+-------+-----------------+
  154. 4 rows in set (0.00 sec)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top