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

  • Home
  • SEARCH
  • 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 9198551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:18:41+00:00 2026-06-17T22:18:41+00:00

in MySQL, I have a row for each user, with a column that contains

  • 0

in MySQL, I have a row for each user, with a column that contains friends names separated by \n.

eg.
Friend1
Friend2
Friend3

I’d like to be able to quickly search all the users where the Friends field contains Friend2.

I’ve found FIND_IN_SET but that only works for commas and the data can contains commas and foreign characters.

Obviously searching with regular expressions and the such will be slow. I’m new to the whole cross referencing so I’d love some help on the best way to structure the data so that it can be found quickly.

Thanks in advance.

Edit: Ok, I forgot to mention a point that the data is coming from a
game where friends names are stored locally and there are no links to
another users ID. Thus the strings. Every time they connect I am given
a dump of their friends names which I use in the background to help match games.

  • 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-17T22:18:42+00:00Added an answer on June 17, 2026 at 10:18 pm

    The most commonly used structure for this kind of data is usually adding an extra table. I.e.

    user
        id,
        name
        email,
        e.t.c.
    
    user_friend
        user_id
        friend_id
    

    Querying this is a matter of querying the tables. I.e.

    List all of a users friends names:

    SELECT friend_id
    FROM user_friend 
    WHERE user_id = :theUser
    

    Edit: Regarding OPs edit. Just storing the names is possible too. In this case the table structure would become:

    user_friend
        user_id
        friend_name
    

    and the query:

    SELECT friend_name 
    FROM user_friend 
    WHERE user_id = :theUser
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a mysql query that targets a single column in a single row
I have a MySQL query that looks like this: UPDATE `Table` SET `Column` =
I have a MYSQL database with 50.000 rows. Each row represents an article. I
I have a table that keeps a count of user actions. Each time an
I have a MySQL database with a growing number of users and each user
I have a table in mysql with a row called 'newrelease'. If the item
Do MySQL have any function by which I can split data of a column
I have MYSQL data like this id | number 1 | 3 4 |
I have mysql database like this id | code 1 | bok-1 2 |
JSfiddle: http://jsfiddle.net/ybZvv/57/ I have a fiddle here where the user can append row 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.