I need to add some of the data from graph A to graph B. Some of the data in graph A is already in graph B, and I don't want to add in duplicate data. How would I write a SPARQL query to find the data that are in graph A but not in graph B? I need to compare the data on five fields. A SELECT query would look like this.
RDF defines that data is not duplicated in an RDF set, so your triplestore should ignore any duplicate values if you attempt to insert them into the graph when they are already present. In that case you can do a simple INSERT/WHERE:
Or, even more simply, if you want add all of the triples from GraphA to GraphB that did not exist in GraphB to begin with then do a SPARQL ADD operation
If you are not actually attempting to modify GraphA but just calculate the difference between the two via a query, then consider the MINUS operator: