r/learnSQL • u/Sabesaroo • Mar 29 '26
Query for combining data from unrelated tables?
I'm brand new to SQL but have a little experience in other languages, mainly Pascal and Python. I have some database coursework and am trying to do some simple tasks with SQL. I assumed I'd be able to do this in 5 minutes but I guess the language is a bit more different than I expected so I feel a bit lost now.
Anyway, I've made a database for an imaginary charity in Libreoffice Base. I've got two main tables, Supporters and Events. Supporters tracks people who signed up to the charity and money they donate, and Events tracks the fundraising events that the charity organises and the amount of funds they raised. There is no field in common between the two.
The query I want to make is summing up the "Donations" column in Supporters, summing up the "Funds Raised" column in Events, and then displaying them both in a small table along with a third column for the combined total. Is something like this even possible, or can you only get data from separate tables by using a JOIN statement? I didn't think that would be appropriate since the tables don't have anything in common.
What I tried so far and didn't work: SELECT SUM( "Supporters"."Donations" ) AS "Donations Sum", SUM( "Events"."Funds Raised" ) AS "Fundraising Sum" FROM Supporters, Events ;
The query runs but generates nonsense numbers that are far too high so I've clearly done something wrong. I'm not convinced by the 'FROM Supporters, Events' part, I wasn't really sure what to put there and it doesn't feel right. Also, even if I do get that to work, I'm not sure how I'll generate the third column with the combined total. I was assuming I could just do SELECT Donations + Funds Raised or something but now I'm not so sure. Is the solution maybe to make another table instead of trying to use a query?
Sorry if it's a dumb question, I imagine I'll learn this stuff myself eventually but I'm kind of in a hurry for this one task.