Hi,
I am trying to figure out how I am suppose to relate all the fields here, any help would be great as I have tried all I know how to get it to work
The tables I use are like so
- messages
- ideas
- id
- message_id
- description
- access
- id
- message_id
- user_id
- group_id
- definition
FROM messages, ideas, access
I need a query that allows me to get all the messages where the user_id is 1 or group_id is 2
WHERE access.user_id=1 OR access.group_id=2
and then have a column showing the message title & description
SELECT messages.title AS title, messages.description AS description,
and then have a column that totals how many ideas a message has
COUNT(*)
with some kind of group by at the end. But also wanting a sum of the definition from access where the user is 1 or group is 2 since there may be multiple rows of access with different definition security
SUM(access.definition)
Any help would be great and especially if this could be turned into one single query. I have had trouble with there being both a count and sum on the two different tables. Please tell me if there are errors in my coding and thinking. Thanks