Jump to content

Recommended Posts

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.

Confusing.

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:

[code]SELECT * FROM sticky_notes,friends WHERE friends.friend = sticky_notes.user LIMIT 5[/code]

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.
Link to comment
https://forums.phpfreaks.com/topic/12414-compare-two-tables-two-colums/
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.