Jump to content

How to take a result like this ?


Rommeo

Recommended Posts

For example you are searching for the username "userPHP"

I want a result like :

 

user1

user335

userAllyss

userPHP | male | 26 years old | likes computers and sea

userRed

userMad

userZero

 

 

What I really want is; I want to print the data in the middle, not at the first or last.

Is there a keyword for this for mySQL ?

 

( I have a users table

username | gender | age | hobbies )

 

 

 

 

 

Link to comment
Share on other sites

I want to print the "search-word" in the middle of all words,

 

if I do : select * from users where user  = %userphp% order by username ASC

 

it will give me the result like

userphp

userxyz

userzero..

 

but I want it like

userabc

userpepe

userphp

userxyz

userzero

 

so if the user was actually trying to find userpepe, he/she needs just to click "userpepe", that s what I m trying to do.

 

( notice that 2 usernames before the "search-word" and two usernames after "search-word" in the result I m trying to get )

 

Link to comment
Share on other sites

I don't follow -- are you saying that mysql is giving you the correct results, but you just want to format to output differently?

Exacty, I just mean that, how can I take the results that are before the correct result and print them ? I need two queries ? or is there a keyword/function for to do that ?

 

Link to comment
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.