Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

Delete rows from a SQL table based on another table

$
0
0

OK.. completely drawing a blank so need some help..

Normally, I would use this simple type of query:

SQL
DELETEFROMTableOneINNERJOINTableTwoONTableOne.Field=TableTwo.Field

But this time, I need it to DELETE only certain records based on several fields, instead of just one.. I know I've done this before using something similar to:
SQL
DELETEFROMTableOneINNERJOINTableTwoWHERETableOne.FieldOne=TableTwo.FieldOneANDTableOne.FieldTwo=TableTwo.FieldFourANDTableOne.FieldSix=TableTwo.FieldTen
But the above code gives me a syntax error. I'm sure it's something simple, but not finding a solution..

Ideas?


Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>