E
E
evil0o2014-07-01 00:30:20
MySQL
evil0o, 2014-07-01 00:30:20

How to invert a selection of records in MySQl?

The task is, there is an array of records that needs to be added to the table (they may already be in the table), and for all other records in the table (which are not in the array), change the activity field to false.
Mono, of course, to "program" but I want to use my mind. So that there are no extra requests.
In essence, you need to select records that are not in the array and set them to false.
let the fields be ID, NAME, ACTIVE

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Petrov, 2014-07-01
@sergoslav_0

Why not do two queries:
1) Set all records to false
2) Add new records (INSERT IGNORE INTO table ...)
?

A
AxisPod, 2014-07-01
@AxisPod

INSERT ON DUPLICATE UPDATE

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question