Welcome Guest, Not a member yet? Register   Sign In
SQL delete on duplicate problem
#1

[eluser]sszynrae[/eluser]
hi, im having some problems with a query meant to do parts of the work of merging together two elements my n-m relational table tagmap

tagmap:
eid (links to the id in my entry table)
tid (links to the id in my tag table)

primary = (eid,tid)

I'm trying to do:
->query('UPDATE tagmap SET tid='.$oldid.' WHERE tid='.$newid.
' ON DUPLICATE DELETE tagmap WHERE tid='.$oldid.' AND eid=VALUES(eid)');

so merging together two tags should here change the tid of all tagmaps from $old to $new
if that entry is already tagged with that tid then i just want to delete the tagmap.

i'm not really familiar with the duplicate syntax, but i'm guessing this should work if there was some way of getting the value the eid field that returned duplicate.

anyone got any ideas on this?




Theme © iAndrew 2016 - Forum software by © MyBB