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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:57:53+00:00 2026-06-05T06:57:53+00:00

I need my MySQL query return value and label field name. I would like

  • 0

I need my MySQL query return “value” and “label” field name.

I would like to have “value” as id of user and “label” as “name lastname” or “*name_first_letter lastname*” directly from the query.

Lets say I have a table like this:

  • id name lastname
  • 1 John Johhanson
  • 2 Peter Petterson
  • 3 Jeff Jefferson

I get the ID as “value” by a simple query: SELECT id as value. I would also like to get “J. Johhanson” or “P. Petterson” as “label“.

UPDATE

Sorry for bothering. I tried CONCAT, CONCAT_WS. Initially unsuccessfully, but now managed to get the results easily.
In my case this query worked as I needed:

SELECT CONCAT_WS(' ', name, lastname ) FROM users
WHERE name LIKE  "%Peter%"

Thank you.

  • 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-05T06:57:54+00:00Added an answer on June 5, 2026 at 6:57 am
    SELECT id                                    AS value, 
           Concat(LEFT(name, 1), '. ', lastname) AS label 
    FROM   table; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to have MySQL query like this one: UPDATE table_name SET 1 =
Basically I have a mysql query something like the following: mysql_query(SELECT n.title, v.value FROM
I need help with a MySQL query. I have three tables: `product_category` ( `id`
I need to used dynamic order query in mysql and i have successfully achieved
I need to use user-defined variable in an INSERT query for MySQL, see an
I have following html form: <form method=post action=> <input type=hidden name=userid id=user value=<?php echo
I have a MySQL query that fetches a numeric value VARCHAR (20) from a
I have a need to return a specific number of rows from a query
I would like to know how I can query MySQL so that entries that
I need a MySQL query (or function) to calculate the geographic midpoint of an

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.