I write a SQL query to query two tables products01 and products02
For all the product02 records, take the substring (the first 10 characters of the volumeId and use these substrings to find all matching records in products01.) Also note that there may be multiple occurrences in products01 the same element, but a different edition.The eleventh character of volumeId makes the volumeId unique.
For example, in products01 I can have volumeId
And in products02, I'd use the substring (volumeId for 10) or "record456" to find those similar records in products01.
In addition, I would like to display the results so that I can verify that my query is accurate.
Here is my initial attempt …
I'm using postgresql.
SELECT a substring (volumeId, for 10) FROM temporary.products01 t01 OR EXISTS ( SELECT volumeId FROM temporary.products02 t02 WHERE t01.volumeId LIKE t02.volumeId);