mysql - INSERT IGNORE for date while ignoring time -


i'm inserting data unique 3 columns using insert ignore. how can exclude time , check date if unique other 2 columns below?

unique index columns: timestamp, action, value

time stamp format: 2016-04-21 13:33:47

my table sample:

2016-04-21 13:33:47, send, email

2016-04-20 11:21:32, send, email

2016-04-19 17:32:65, send, email

what i'm trying do: if try insert data below, should ignored because there's existing data 2016-04-21, send, email.

2016-04-21 19:33:47, send, email

the way ignore work if have 1 or more columns in unique index. in case need date field that's derived datetime.

for example:

alter table my_emails add column sent_date date create unique index idx_sent_date on my_emails (sent_date) 

then can populate it:

update my_emails set sent_date=date(sent_datetime) 

with whatever columns are. point forward you'll need sure populate both fields.


Comments

Popular posts from this blog

Why does Go error when trying to marshal this JSON? -

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

python - Pygame. TypeError: 'pygame.Surface' object is not callable -