lundi 4 janvier 2016

can we implement innerjoin in the following sql query

CREATE TABLE forgerock (id INT, [date] DATETIME, empcode INT,[file] VARCHAR);
INSERT INTO forgerock
VALUES
    (1, '2015-12-31 01:20:02', 56, 'abc1'),
    (2, '2016-01-01 01:20:02', 58, 'abc2'),
    (3, '2016-01-02 01:20:02', 46, 'abc3'),
    (4, '2016-01-03 01:20:02', 16, 'abc4'),
    (5, '2016-01-04 01:20:02', 36, 'abc5');

CREATE TABLE forge (empcode INT, [user_name] VARCHAR);
INSERT INTO forge
VALUES
    (56, 'ram'),
    (58, 'ram1'),
    (46, 'ram2'),
    (16, 'ram3'),
    (36, 'ram4');

this are my table.i try to print the file name and user_name from the tables with respect to current date and the day before the current date

i tried the query

ResultSet resultset = statement.executeQuery("select file  from forgerock where '"+date+"' >= CURRENT_DATE('"+date+"', INTERVAL 1 DAY);") ;

but i got the exception

Incorrect syntax near the keyword 'CURRENT_DATE'.

how can i print the file and user_name with respect to DATETIME(current date and day before the current date)

Aucun commentaire:

Enregistrer un commentaire