Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7899673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:45:59+00:00 2026-06-03T08:45:59+00:00

I want to do a contacts page. Here is my table structure: Accounts Table:

  • 0

I want to do a contacts page. Here is my table structure:

Accounts Table: 

1) id
2) User_id
3) Full_name
4) Username
5) Email
6) Password

Contacts Table: 

1) My_id (This is the user who added friend_id)
2) Contact_id (this is the contact who was added by my_id)
3) Status

My query looks something like this:

$sid = ID of user who is viewing;

$sql = "SELECT STRAIGHT_JOIN DISTINCT contacts.contact_id, 
accounts.full_name FROM contacts INNER JOIN accounts
on contacts.contact_id = accounts.user_id WHERE 
contacts.my_id = '$sid' OR contacts.contact_id = '$sid'"; 

The problem is that it doesn’t work the right way. I end up seeing my name in the query (meaning when i login i see my name in the contacts instead of contacts name).

How to fix this? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T08:46:01+00:00Added an answer on June 3, 2026 at 8:46 am

    This query ought to suffice:

    SELECT DISTINCT contacts.contact_id, accounts.full_name
    FROM contacts, accounts
    WHERE (contacts.my_id = '$sid' AND contacts.contact_id = accounts.user_id)
    OR (contacts.contact_id = '$sid' AND contacts.my_id = accounts.user_id)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want menu in my page to look like this: About us | Contacts
This rule works fine for http://foo.com/page/contact RewriteRule ^page/([^/\.]+)/?$ index.php?page=$1 [L] But what I want
Here's what I want to achieve: www.mydomain.com/pages/23/page-title-hash-here -> www.mydomain.com/pages.php/23 www.mydomain.com/[otherpages] -> www.mydomain.com/[otherpages].php www.mydomain.com/[otherpages]/ ->
I want to read a particular contact from contacts,say john, and to display all
I want to read all the contacts from the phone but i am unable
I want to ask a question about the Contacts on objective C. I am
So i want to show a contacts list and for that I have transformed
I'm writing a contacts & events database and want to view those contacts that
I have seen the Contacts in iPhone Simulator. I want to create an application
I'm retriving contacts from WP7. Some contacts having images some not having. I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.