Ceriwis

Ceriwis (https://forum.ceriwis.com/forum.php)
-   Programming (https://forum.ceriwis.com/forumdisplay.php?f=63)
-   -   [ask] NEED DEWA SQL : update row where id=n, if not exist then insert? (https://forum.ceriwis.com/showthread.php?t=573607)

Permenkaret 20th November 2011 01:59 AM

[ask] NEED DEWA SQL : update row where id=n, if not exist then insert?
 
Selamat malem gan...

sesuai judul nih...

ane punya beberapa baris data

misal




Code:

id | a
------------
1 | hello
2 | world
------------

trus ane mau masukin lg baris ke-3

biar gini




Code:

id | a
------------
1 | hello
2 | my
3 | world
------------

permasalahan :

1. datanya bnyk bgt, untuk cek satu" pasti memakan waktu.

2. data yg udah disimpen kemungkinan di update lg.

3. pas update data baru pasti ada data yg dimasukin lg.



tujuan :

bisa gak sih dibikin

UPDATE SET a='x' WHERE id=2 IF NOT EXIST INSERT INTO .........



hasil Google :

ane cuma nemu yg INSERT IF KEY DUPLICATE UPDATE ....







mohon pencerahan :loveindonesia

</div>


All times are GMT +7. The time now is 11:14 AM.