Jump to content

[SOLVED] DELETE JOIN


jaymc

Recommended Posts

I have just ventured into using JOINS for mass row deletion accross tables

 

However, i notice that adding a limit (LIMIT 5) for example renders the query useless

 

Without the limit its fine, but takes longer because it has to carry on after it deletes 5 rows

 

Is this just the way it works, becasuse Id rather add a limit when I know for certain Im only deleting 5 rows, 1 rows in each of the 5 tables for instance

Link to comment
https://forums.phpfreaks.com/topic/97818-solved-delete-join/
Share on other sites

Same issue with JOIN for an UPDATE, it doesnt like having LIMIT in there, here is an example, works without UPDATE but not with.

 

$q = "UPDATE members m

INNER JOIN members_info mi ON m.username = mi.username

SET

fullname = '$fullname',

loc = '$location',

nightclub = '$nightclub',

footyteam = '$football',

relationship = '$relationship',

profession = '$profession',

favmusic = '$music',

sexuality = '$sexuality',

mi.info = '$message'

WHERE m.username = '$User_Session'

LIMIT 1";

Link to comment
https://forums.phpfreaks.com/topic/97818-solved-delete-join/#findComment-504082
Share on other sites

Try this statement

$q = "UPDATE members, members_info 
   SET
   fullname    = '$fullname',
   loc       = '$location',
   nightclub    = '$nightclub',
   footyteam    = '$football',
   relationship    = '$relationship',
   profession    = '$profession',
   favmusic    = '$music',
   sexuality    = '$sexuality',
   members_info.info    = '$message'
   WHERE members.username = members_info.username AND members.username = '$User_Session'
   LIMIT 1";

Link to comment
https://forums.phpfreaks.com/topic/97818-solved-delete-join/#findComment-504789
Share on other sites

No, doesnt work. Heres what I used

 

$q = "UPDATE members m, members_info mi
SET
fullname 	= '$fullname',
loc 		= '$location',
nightclub 	= '$nightclub',
footyteam 	= '$football',
relationship 	= '$relationship',
profession 	= '$profession',
favmusic 	= '$music',
sexuality 	= '$sexuality',
mi.info 	= '$message'
WHERE m.username = mi.username AND m.username = '$User_Session'
LIMIT 1";

Link to comment
https://forums.phpfreaks.com/topic/97818-solved-delete-join/#findComment-505020
Share on other sites

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.