Delete records

  • Thread starter Thread starter Daniel
  • Start date Start date
D

Daniel

In a table I have two columns that may sometimes hold the
same codes, for Example:

Col1 Col2
xxxx xxxx
yyyy zzzz
pppp pppp

I need to run a query that will update col1 to null where
the code is the same as what is in col2 so the rsult
would be:
Col1 Col2
xxxx
yyyy zzzz
pppp

How would I go about this...please help...really stuck
with this!

Thanks
 
Daniel,

Open a new query in design view, select the table and drag and drop the two
fields from the table down to the grid. Then in the grid, under Col2, type
[Col1] in the first criteria line (if the name of the filed is not Col1 then
type in tyhe exact name of the field). So far you have a Select query that
selects records where Col1 = Col2. Switch to datasheet view to verify. Then,
back to the design view, go to menu Query > Update query, to change the type
of your query from Select to Update. Notice the new line headed Update To
that appears in the grid. Go to that line under field Col1 and type in it
"Null" (without the quotes). Now go to menu Query > Run, confirm when
prompted to accept the cahnges, and you're done.

HTH,
Nikos
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

matching tables 2
ComboBox in DataGridView 1
Displaying Data 1
VB .NET SQL issue 2
sum column 1
sum 2 columns with equal names 1
Update datarow 2
Match based on a lookup and then flag 4

Back
Top