• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!
Collapse

You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:

  • You are not logged in. If you are already registered, fill in the form below to log in, or follow the "Sign Up" link to register a new account.
  • You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
  • If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.

Previously on "SQL help, structuring a delete."

Collapse

  • minestrone
    replied
    Cheers, i'll give that a whirl.

    Leave a comment:


  • Zippy
    replied
    Originally posted by MrMark View Post
    Hi - I'm getting a bit rusty on this now, but I'm fairly sure that Mysql isn't hot at handling sub-queries performance wise. Better to write a delete using a join statement:

    DELETE t1 FROM tbl_name t1, tbl_name t2
    WHERE t1.roleID=t2.roleID
    AND t1.roleName=t2.roleName
    I've got nowt better to do so I looked it up (haven't done an mySQL for years).
    There is a problem with using sub-queries and DELETE but you can use correlated sub-queries.

    Leave a comment:


  • MrMark
    replied
    Originally posted by minestrone View Post
    Anyone know how this could be done...

    I have a table (table1) of name value pairs.

    role_id & role_name

    I also have a table (table2) of the same columns which is basically a data subset of table 1. I wish to remove all the entries contained in table2 from table 1.

    As the primary key is over both colums I don't know how to do this. What I want to do is kind of like..



    But obviously that does not work. The DB is mySQL

    Cheers for any help
    Hi - I'm getting a bit rusty on this now, but I'm fairly sure that Mysql isn't hot at handling sub-queries performance wise. Better to write a delete using a join statement:

    DELETE t1 FROM tbl_name t1, tbl_name t2
    WHERE t1.roleID=t2.roleID
    AND t1.roleName=t2.roleName

    Leave a comment:


  • minestrone
    replied
    I'll give that a blast when I get back on my laptop when I am on the train.

    I head to the pub most days to work on plan B for an hour.

    Leave a comment:


  • thunderlizard
    replied
    now in Oracle, that would have worked (with a little reordering of brackets).

    How about something nice and hacky like
    where role_id || " & " || role_name in...
    or whatever the concatenation operator is in MySql.

    Leave a comment:


  • minestrone
    started a topic SQL help, structuring a delete.

    SQL help, structuring a delete.

    Anyone know how this could be done...

    I have a table (table1) of name value pairs.

    role_id & role_name

    I also have a table (table2) of the same columns which is basically a data subset of table 1. I wish to remove all the entries contained in table2 from table 1.

    As the primary key is over both colums I don't know how to do this. What I want to do is kind of like..

    DELETE from
    table1
    WHERE
    role_id , role value
    IN
    (SELECT
    role_id , role value
    FROM
    table 2) ;
    But obviously that does not work. The DB is mySQL

    Cheers for any help
Working...
X