Clinical trials with control groups. The key is randomly assigning people to either the test group or the control group. Then you vaccinate one group and not the other. And then you follow both groups around to see how they fare. It's a statistical thing so it's important to have large number of participants.
If done honestly and with integrity the trials can tell us whether a drug is effective.
In the case of covid 19 the trials are done by the very companies that sell the vaccines. The phase 3 trials are still ongoing and they vaccinated the control group so that when they conclude the results will be worthless.
(post is archived)