简体   繁体   中英

Select a value and set it in a variable in mysql

this is my problem:

I have a result of a SELECT that show me some value like first name and last name of a user.

Example:

Firstname = "First"
Lastname = "Last"

Now I want to get another value that is the result of another select (SELECT * FROM x WHERE y = z)

Example:

Firstname = "First"
Lastname = "Last"
NewValue = "true" (or false)

How can I do this?

do you mean something like this

 select Firstname , Lastname , (select column from another_table ) as NewValue
 from myTable
SELECT Firstname, Lastname, 
       (SELECT ColumnName AS NewValue
        FROM table_Name2
        WHERE (your condition goes here)       
FROM table_Name1
WHERE (your condition goes here)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM