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 6858241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:08:00+00:00 2026-05-27T02:08:00+00:00

Oke my website works with Facebook Api, it will import all the friends (userId,

  • 0

Oke my website works with Facebook Api, it will import all the friends (userId, name) of the user that will be logged in so my table structure is as following:

users: id, name
usersFriends: id, friendUserId, name

So when the users join the website, they will get all the friends imported, example data:

user: 237374734 (facebook user id), John brouwers (name of the user)

then it will import all the friends of John. for example:

userFriends: 237374734 (John user id), 2737373, Michael jackson

Now what I need is a query that will SEARCH (by name) through the friends, which is
no problem with just a join, but what I need is in the query I need to CHECK whether the user is on my website so lets take an example:

We logged in with the user John, and we are searching for michael so that would be

SELECT name FROM userFriends WHERE name LIKE %michael%

But what I need is NOT only return the name of the user, I also need a CHECK whether the user exists in the users table.

Sorry for the long story, hope that my question is clear. Thanks already!

  • 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-05-27T02:08:00+00:00Added an answer on May 27, 2026 at 2:08 am

    Edit: So you need a query that search friends by Name and check whether the friend exists in the users table or not, As follows:

    create table Users(
       Id int not null,
       primary key (Id),
       Name varchar(50) not null
    )TYPE=MyISAM;
    create table UserFriends(
       Id int not null,
       foreign key (Id) references Users(Id),
       FriendUserId int not null,
       Name varchar(50) not null
    )Type=MyISAM;
    insert into Users(Id,Name) values(237374734,'John brouwers');
    insert into UserFriends(Id,FriendUserId,Name)
    values(237374734, 2737373, 'Michael jackson');
    

    Here is the query that will search for the suer that his name like "%Michael%" and check if he is a registered user or not:

    select s.Id, s.Name, 
           case when exists 
           ( 
               select Name from users where Name like "%Michael%" 
           ) Then 'Registered User'
           else
           (
               'Not Registered'
           )
           end
           as 'Is Registered in My Website'
    from 
    (
          select uf.FriendUserId Id, uf.Name
          from UserFriends uf
          left join users u on u.Id = uf.friendUserId
          where uf.name like "%Michael%"
    ) s
    

    This will gives you:

    Id              Name        Is Registered in My Website
    2737373   Michael jackson        Not Registered
    

    Hope this will be helpful and if there is any problems don’t hesitate to ask.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please see attached image alt text http://img248.imageshack.us/img248/7743/datefrom.png I have a table which have FromDate
I have a Datagridview, on which I need to validate the user input on
In my controller, the following works (prints oké) puts obj.inspect But this doesn't (renders
I can't imagine that there doesn't exist an efficient, lightweight, secure authentication and authorization
i have large form in my website and using serialize() to process the form.
Oke so i updated the Question whit the full class included the problem is
Key Entity: @Entity public class KeyEntity { @Id @GeneratedValue(strategy = GenerationType.TABLE) public Long id;
I have make a soap-call with Savon. This works fine and give the following
I am developping facebook apps therefore i need to setup ssl certificates and i
I am making a customized menu, with customized menu Items. Changing control templates and

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.