Jump to content


Compare two tables, two colums

  • Please log in to reply
No replies to this topic

#1 shanparker

  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 19 June 2006 - 09:17 PM

I have this query semi finished. I have two tables. I need to query the first table for only entries where the "user" field is valid because it's a user in the "friends" table. I have that working. The third thing it needs to do is make sure that the user who is logged in is in friends table column.


The site I'm working on is a Myspace type site - so two entries go into the friends table when a friend link is created. An association each way for the friend. Friend 1 is friends with Friend 2, and a second one to show that Friend 2 is friends with Friend 1. The query I have written so far checks that they are friends - but it returns two results instead of one from the sticky_notes table because it's reading the two associations.

The query so far is:

SELECT * FROM sticky_notes,friends WHERE friends.friend = sticky_notes.user LIMIT 5

Now all I need to do is to get it to check for the third value. That the user (in the friends table) is the user who is logged in (which is the value $session->username).

I assume I'm on the right path here.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users