First, i have 4 table and columns such as
- feeds (id, type, type_id)
- feeds_normals (id, type, content)
- feeds_links (id, type, title, link)
- feeds_youtubes (id, type, title, link, description, image)
- feeds_photos (id, type, link)
The table of "feeds type_id" is match/linkup "id" of normals, links, youtubes, photos
And
The table of "feeds type" is using the identified which table should be joined
For example:
feeds:
id: 1, type: "normal", type_id: 1
id: 2, type: "link", type_id: 1
feeds_normals:
id: 1, type: "normal", content: "this is a test"
feeds_links:
id: 1, type: "link", title: "This is a title", link: "http://yahoo.com"
Result:
id: 1, type: "normal", content: "this is a test", title: NULL, link: NULL
id: 2, type: "link", content: NULL, title: "This is a title", link: "http://yahoo.com"
Finally
In this case, how to write by SQL statement?