Just need some guidance on the best way to make a query on the database.
I am building a site that has your status updates feature and comments for that status update.
Just not sure how to write the sql to pull it all out. I am running a query to get all the status updates assumed I would need to run another query while looping / printing out each status to get all the comments, but there must be another more efficient way.
I have two tables, one for statuses and the other for comments with the status id as key in comments. This is what I was thinking of doing but it looks really inefficient having to run two queries on the database. Any help appreciated.
select * from status
foreach statuses as status
select * from comments where status_id = status_id
foreach comments as comment
What is the structure of each table?
What fields (and from which table) are required in the result set?
statusid, userid, status, date,
commentid, userid, statusid, date, comment
So i basically want to list all the statuses and underneith each status all the comments on that status. As in my previous post, I can do this using nested for loops and queries, but is there any way I can just run one query and pull out all the data at once?
This topic is now closed. New replies are no longer allowed.