I have a question quite similar to the one in Comparing two tables (20 January 2003).
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
I have a table that has two columns - author name (authname) and first author name (fauthname). The pk is authId. I need to compare the data in these two fields, and if any data in fauthname already exists in authname then I need it to be temporarily deleted, and any data not currently existing in authname should be added to authname. My goal is to be able to count the total number of authors. Am I making this harder than it is?
Yes. If all you want is to count the number of distinct authors, you are.
There are many ways to do it. Here's the easiest:
select count(*) from ( select authname from yourtable union select fauthname from yourtable )
UNION removes duplicates (UNION ALL would preserve them). Then just take the count.
Dig Deeper on Oracle and SQL
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.