Use CURRENT_DATE in where clause : Where « Where Clause « SQL / MySQL






Use CURRENT_DATE in where clause

      
mysql>
mysql> CREATE   TABLE PENALTIES
    ->         (PAYMENTNO      INTEGER      NOT NULL,
    ->          EmployeeNO       INTEGER      NOT NULL,
    ->          PAYMENT_DATE   DATE         NOT NULL,
    ->          AMOUNT         DECIMAL(7,2) NOT NULL,
    ->          PRIMARY KEY    (PAYMENTNO)          );
Query OK, 0 rows affected (0.00 sec)

mysql>
mysql> INSERT INTO PENALTIES VALUES (1,  6, '1980-12-08',100);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO PENALTIES VALUES (2, 44, '1981-05-05', 75);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO PENALTIES VALUES (3, 27, '1983-09-10',100);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO PENALTIES VALUES (4,104, '1984-12-08', 50);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO PENALTIES VALUES (5, 44, '1980-12-08', 25);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO PENALTIES VALUES (6,  8, '1980-12-08', 25);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO PENALTIES VALUES (7, 44, '1982-12-30', 30);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO PENALTIES VALUES (8, 27, '1984-11-12', 75);
Query OK, 1 row affected (0.00 sec)

mysql>
mysql> SELECT   *
    -> FROM     PENALTIES
    -> WHERE    PAYMENT_DATE = CURRENT_DATE;
Empty set (0.00 sec)

mysql>
mysql>
mysql> drop table penalties;
Query OK, 0 rows affected (0.00 sec)

   
    
    
    
    
    
  








Related examples in the same category

1.Not equal in where
2.Getting the List of Products That Are on Catalog Promotion
3.Using Where Conditions
4.WHERE Clause Comparisons
5.Combining WHERE Conditions
6.Calculation in WHERE clause
7.Compare and calculate in Where clause
8.Do Calculation in Where and order
9.Where clause: nested conditions
10.Where clause: calculation and equal condition
11.Where clause: compare
12.Where clause: XOR
13.Use where clause the narrow down results
14.WHERE TRUE OR FALSE
15.Change localhost to the name of the machine where you'll be working.
16.WHERE clauses can test multiple conditions.
17.To put first those records where people sent messages to themselves
18.Using a WHERE clause that matches up values in the author ID column
19.Add a WHERE clause that looks for NULL values in the book column that is named in the ON clause
20.Add an expression to the WHERE clause that explicitly excludes the reference
21.Adds an additional condition to the WHERE clause and the calculated columns must have a total greater than 20
22.A WHERE clause that contains two expressions (conditions)
23.Searches for surnames that have an e anywhere in the name and then end with an e:
24.Show all records where the color is "Silver" and the price is above 100.00
25.Show records where make is "Krups", "Gaggia" or "DeLonghi" and the model is not "TSK-182" or "EC410"
26.Show all records where the color is not "Silver" or the price is below 100.00
27.Get the number of items for each color where the price exceeds 150.00 and when there is more than 1 item for t
28.Check day name in where clause
29.Compare the results from two statements