Hi,
I’m struggling to get my head around how to structure a query for a profile page on my site.
A basic version of the query is as follows -
SELECT `users`.`uid`
, `users`.`name`
, `users`.`email`
, `user_groups`.`name` AS `group_name`
, `user_groups`.`premium`
FROM `users`
INNER
JOIN user_groups
ON user_groups.id = users.user_group_id
WHERE `users`.`uid` = '{$uid}'
LIMIT 1;
This is working fine for now but I want to add a posts section on each profile. The posts table in basic form consists of -
- pid (post id)
- name
- content
- uid (user id)
So I need a query that will loop through the posts table and get every post the user has made (which can be 0). Is it viable to use just 1 query here still or do I just need to do a simple query using "WHERE uid
= ‘{$uid}’ from the post table?