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
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
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
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
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.