Home > database >  The operation can simplify the code?
The operation can simplify the code?

Time:10-14

An existing table T1, there were fields and the content is as follows:
IP MAC dep loca user time
12 aa xx xx xx 2019

Which IP, MAC, dep, loca, the user to merge the only ( because of what I need is, these five literally a change, is a new data to distinguish between ), namely,
The ALTER TABLE ` T1 ` ADD UNIQUE (` IP ` ` MAC `, ` dep `, ` loca `, ` user `);

I am in the process of operation, if changed the above five one (not sure which change is), I have used ON the DUPLICATE KEY UPDATE to write, the other four how to use the data before didn't change back

The assumption now dep changed, become ff, use ON the DUPLICATE KEY UPDATE will automatically add a record, but increase the records of other four if it weren't for a null value, if it weren't for the default, how do I retrieve the data ON the value of the (namely IP=12, MAC=aa, loca=xx, xx, user=time=2019)?

Thank you ~

CodePudding user response:

If ON the DUPLICATE KEY UPDATE can't write with other statements can be, as long as you can complete the above actions,

CodePudding user response:

Direct INSERT not just yao, in addition to change a, all the other items directly to check the original data
  • Related