Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieving data from a database with relationships

Tags:

sql

php

mysqli

I am trying to retrieve some data from my database, I have already made the right relationships inside the database but I just can't get my head around which query to use.

Here is a visual representation of the different relationships: phpmyadmin

What I want is to get all data from clanwars aswel as all usernames from the users who have applied for these wars.

Can you guys help me?

Thanks in advance!

like image 908
Dennishofken Avatar asked May 08 '26 03:05

Dennishofken


1 Answers

How about:

select w.*, m.username
  from clanwars w
  join applications a on a.warid = w.id
  join members m on m.id = a.playerid
like image 91
The Impaler Avatar answered May 09 '26 18:05

The Impaler



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!