I have two tables:
socials and social_links
I want all rows from first table and related rows from second table.
My code:
SELECT socials.*, social_links.*
FROM socials
LEFT JOIN social_links ON socials.id=social_links.social_id
WHERE social_links.site_id=1
This code return 2 rows, but I want 4 rows where site_id=1.
First table socials:
| id | name |
|---|---|
| 1 | |
| 2 | |
| 3 | |
| 4 | Messenger |
Second table social_links:
| id | social_id | site_id | link |
|---|---|---|---|
| 1 | 1 | 1 | https://www.facebook.com/lolo |
| 2 | 2 | 1 | https://instagram.com/test |
| 3 | 1 | 2 | https://www.facebook.com/koko |
I want all rows from socials join with social_links where site_id=1.