Jump to content

[SOLVED] Query Question


jboog

Recommended Posts

gotta be something small...

 

quivergroup is made up of boards.

Fetch the subscription to 'subscribed''s boards if privacy is 1 and 'user' isn't on 'subscribed''s block list.

Something around the NOT?

 

SELECT boards.boardid, boards.userid, boards.boardname, brand, model, lengthft, lengthin, quivergroup.quid, quivergroup.quivername, boards.timestamp
FROM boards,subscriptions,quivergroup,messageblocks
WHERE subscriptions.username = 'user'
AND subscriptions.resource = 'boards'
AND (quivergroup.privacy = '1' AND NOT (messageblocks.username = subscriptions.subscribed AND messageblocks.blockeduser = 'user'))
AND boards.userid = subscriptions.subscribed
AND boards.quid = quivergroup.quid
ORDER BY boards.timestamp DESC LIMIT 1

 

Subscriptions:

id,username,subscribed,resource,timestamp

1, 'user', 'user2', 'boards', '200704221523'

 

Quivergroup:

id,userid,quivername,privacy,picgal,timestamp

9, 'user2', 'Old Boards', 1, 12, '200703181551'

 

Boards:

id,userid,boardtitle,etc...

34, 'user2', 'asd', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, '', 'Bat', 'FCS', 1, '', '', 9, '200704221648'

 

Messageblocks:

empty

 

Thanks

 

Link to comment
https://forums.phpfreaks.com/topic/48873-solved-query-question/
Share on other sites

SELECT boards.boardid, boards.userid, boards.boardname, brand, model, lengthft, lengthin, quivergroup.quid, quivergroup.quivername, boards.timestamp
FROM boards
LEFT JOIN quivergroup
ON boards.quid = quivergroup.quid
LEFT JOIN subscriptions
ON boards.userid = subscriptions.subscribed
LEFT JOIN messageblocks
ON boards.userid = messageblocks.username
WHERE subscriptions.username = 'user'
AND subscriptions.resource = 'boards'
AND (quivergroup.privacy = '1' AND messageblocks.blockeduser != 'user')
ORDER BY boards.timestamp DESC LIMIT 1

 

So my new question is: I want to get results where there is no row in messageblocks where messageblocks.username = boards.userid AND messageblocks.blockeduser = 'user'...The above query doesn't work if messageblocks.username has no rows in messageblocks. Any ideas?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/48873-solved-query-question/#findComment-241171
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.