• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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?


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.