Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.