If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > stuck on this

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-18-06, 08:54
wiskers wiskers is offline
Registered User
 
Join Date: May 2006
Posts: 1
Arrow stuck on this

I have the following three tables:

items
id
title
brief_description
user_id

community
user_id
friend_id
type (0 | 1) if type == 1 : you are friends, if type == 0: tracking the user

item_invitations
item_id
user_id

Right now, I use this code:

$sql = 'SELECT i.id, i.title, i.brief_description FROM items i INNER JOIN community c ON i.user_id = c.friend_id WHERE c.user_id = ' . $_SESSION['user_id'] . ' AND i.visibility = 1';

That shows me all items in my community where the visibility == 1.

visibility = 1 means that everyone can see it.

visibility = 2 means only friends can see it.

visibility = 3 means you need an invitation to see it.

I want to include visibility 2 and 3 in the query, if possible.

Below is some pseudo code on how to do that but i really don't know how to implement this in SQL.

if i.visibility == 2
then community.type must be 1
if i.visibility == 3
then item_invitations.item_id = i.id AND item_invitations.user_id = $_SESSION['user_id']

Thanks
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On