I have these three tables,
page
table
page_id page_title
1 a
content
table
content_id content_text
1 text one
2 text two
content structure
table
page_id content_id order_in_page
1 1 1
1 2 2
my working sql,
SELECT
p.*,
c.*,
x.*
FROM pages AS p
LEFT JOIN pages_structures AS x
ON x.page_id = p.page_id
LEFT JOIN pages_contents AS c
ON c.content_id = x.content_id
WHERE p.page_url = 'a'
result,
page_id page_title content_text order_in_page
1 a text one 1
1 a text two 2
the result I am after
page_id page_title content_1 content_2 content_3 content_4
1 a text one text two null null
How can I make the multi-row result into a single row result?
Or maybe the multi rows result is better and faster than a single row result that I want?
EDIT:
the reason I want a single row result is that I can just call the content_# by doing this,
echo $page['content_1'];
just like I call the title,
echo $page['page_title'];