473,320 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

sql deletion with delimiters

3
Have a problem with deletion that contains delimiters:

tb2 & tb3 contains Dept like: GM/ACCT/FIN
Want to delete it such that Dept is not found in tb1 & tb2

This query will still delete even if is found in tb1 & tb2:

Expand|Select|Wrap|Line Numbers
  1. delete a from tb1 a left join tb2 b on b.Dept=a.Dept
  2. left join tb3 c on c.Dept=a.Dept
  3. where a.Dept=@dept and b.Dept is null and c.Dept is Null
  4.  
Jul 1 '09 #1
3 1673
Set null to Null as im not sure if it is case sensitive. Your variable should be in quotes also. Try this...

Expand|Select|Wrap|Line Numbers
  1. delete a from tb1 a left join tb2 b using(Dept)
  2. left join tb3 c using(Dept)
  3. where(a.Dept='@dept' and b.Dept is Null and c.Dept is Null )
Jul 1 '09 #2
naanaa
3
hi daniel2335,

this could not work as using is an incorrect syntax.

Still have problem with this query:
tb2 & tb3 contains Dept like: GM/ACCT/FIN
Want to delete it such that Dept is not found in tb1 & tb2
Expand|Select|Wrap|Line Numbers
  1. Delete a from t1 a left join t2 b on b.FirstName LIKE '%a.FirstName%'
  2. left join t3 c on c.FirstName LIKE '%a.FirstName%'
  3. where a.FirstName LIKE '%GM%'
  4. and b.FirstName is null and c.FirstName is Null
  5.  
Jul 1 '09 #3
I may be clutching at straws but it may have been because I didn't put a space after using. Does this work?

Expand|Select|Wrap|Line Numbers
  1. delete a from tb1 a left join tb2 b using (Dept) 
  2. left join tb3 c using (Dept) 
  3. where (a.Dept='@dept' and b.Dept is Null and c.Dept is Null ) 
Are you storing multiple departments in a single field? This is bad database design and is making it hard to get your data back. Google "mysql normalization tutorial"(more american links :P) They will show you how to better your database design.
Jul 1 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Markus Elfring | last post by:
Hello, I try to use alternative delimiters for a regular expression. When will it be supported? www@mike:/home/www > /usr/local/bin/php -a Interactive mode enabled <?php...
3
by: Justin L. Kennedy | last post by:
I am looking for a function that takes in a string and splits it using a list of other strings (delimiters) and can return the delimiters as well as the extra parts of the string. I was trying the...
2
by: Bill Moran | last post by:
I'm having some problems using \copy I have a directory full of test data that I want to be installed automatically when "make database" is issued. While the Makefile rules would seem simple,...
3
by: A_Republican | last post by:
I am interested in writing my own secure file deletion program. I want to be able to read and write to my hard drive directly. My application will seach my hard drive for all locations marked for...
6
m6s
by: m6s | last post by:
1. After hours of researching, I used these snippets : void Object::TokenizeLines(const string& str, vector<string>& tokens, const string& delimiters) // Skip delimiters at beginning....
4
by: bearophileHUGS | last post by:
This is the best praise of semantic indentation I have read so far, by Chris Okasaki: http://okasaki.blogspot.com/2008/02/in-praise-of-mandatory-indentation-for.html A quotation: I have...
1
by: zeny | last post by:
Hey folks! Can anyone tell me how to add data to a table using "copy" with several delimiters? Is it possible? What i mean is: Copy <table_name> from <file_directory> using delimiters...
5
by: gpaps87 | last post by:
hi, i wanted to know whether we can use strtok command to mark delimiters as tokens as well.In Java,we have a command: StringTokennizer(String str, String delimiters, boolean delimAsToken) ...
4
by: Marco Trapanese | last post by:
Hi, I'm trying to parse strings on an Atmel AVR device. I use the WinAVR C Compiler (GCC) The strings to parse are like this: command -par0 -par1 -parn I use strok_r function:
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.