- 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!
Reply to: SQL help, structuring a delete.
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.
Logging in...
Previously on "SQL help, structuring a delete."
Collapse
-
I've got nowt better to do so I looked it up (haven't done an mySQL for years).Originally posted by MrMark View PostHi - 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
There is a problem with using sub-queries and DELETE but you can use correlated sub-queries.
Leave a comment:
-
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:Originally posted by minestrone View PostAnyone 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
DELETE t1 FROM tbl_name t1, tbl_name t2
WHERE t1.roleID=t2.roleID
AND t1.roleName=t2.roleName
Leave a comment:
-
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:
-
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:
-
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..
But obviously that does not work. The DB is mySQLDELETE from
table1
WHERE
role_id , role value
IN
(SELECT
role_id , role value
FROM
table 2) ;
Cheers for any helpTags: None
- Home
- News & Features
- First Timers
- IR35 / S660 / BN66
- Employee Benefit Trusts
- Agency Workers Regulations
- MSC Legislation
- Limited Companies
- Dividends
- Umbrella Company
- VAT / Flat Rate VAT
- Job News & Guides
- Money News & Guides
- Guide to Contracts
- Successful Contracting
- Contracting Overseas
- Contractor Calculators
- MVL
- Contractor Expenses
Advertisers
Contractor Services
CUK News
- HMRC standstill agreements extended to 72 months: why the term's doubled, and what to check before signing Today 05:53
- Who owns the loans? Inside the mystery of the loan charge recall scandal Yesterday 06:20
- Umbrella company winding-up petitions in 2026: the practical guide for contractors Jul 29 05:29
- Payments on Account deadline: what contractors must do before July 31st — maybe for the final few times Jul 28 08:01
- Andy Burnham's first 100 days: five things contractors need from the new PM Jul 27 00:53
- Starmer vs Burnham on housing: What their rival plans mean for your contractor mortgage Jul 22 00:59
- Burnham's housing vision vs. Starmer's home-buying reforms: what it means for your contractor mortgage Jul 22 00:59
- In Khalil v Innovate Transport, a limited company contractor wasn’t a worker and was on £2.30 — not £230 Jul 21 07:58
- Andy Burnham is PM: 5 new IT policies set to shape UK tech and its contractors Jul 20 06:29
- Taxed on money I haven't earned yet? Bold move, HMRC Jul 17 08:36

Leave a comment: