I am making a simple angular + nodeJS + MySQL application, for learning purposes.
I am trying to understand how to use this table in MySQL Exchange before implementing the deletion in my app.
This is my table -
create table taskstable
(
instanceTime timestamp not null,
item varchar(45) not null,
email varchar(255) not null,
ischeck boolean not null,
foreign key (email) references usertable(email),
primary key (instanceTime, email)
);
And I insert these values (one at a time so they have different timestamps)
insert into taskstable
values (current_timestamp,"to call mom","[email protected]",false);
insert into taskstable
values (current_timestamp,"write papter","[email protected]",false);
insert into taskstable
values (current_timestamp,"paint chair","[email protected]",false);
Now, these are the values in my table:
# instanceTime, item, email, ischeck
2018-02-10 16:19:12, to call mom, [email protected], 0
2018-02-10 16:19:29, write papter, [email protected], 0
2018-02-10 16:19:33, paint chair, [email protected], 0
And when I try to delete using this:
DELETE FROM taskstable
WHERE (current_timestamp like "2018-02-10 16:19:12" AND email like "[email protected]");
And the result is this: 16:24:22 DELETE FROM taskstable WHERE (current_timestamp like "2018-02-10 16:19:12" AND email like "[email protected]") 0 row(s) affected 0.000 sec
Which means I don't use the timestamp object well. I am new in MySQL and not sure how to approach this. How should I delete?
Edit, this was a mistake, I should of asked "instanceTime LIKE blabla"
But now, when I try to delete with my app, the Json receive the time info this way: "instanceTime":"2018-02-10T14:19:29.000Z" But SQL should be: "2018-02-10 14:19:29"
What is this formatting shown in the JSON? How to show the right formatting?!
DELETE FROM
taskstable
WHERE
instanceTime = "2018-02-10 16:19:12" AND
email = "[email protected]"
You can delete like this.