选择即时创建的字段

Assume a table bank contains 3 fields, id, name, and balance.

I am trying to understand how to select all fields from this table and add another custom field to the result set as follows:

Query (something like)

SELECT * FROM bank WHERE balance+10 AS plusTen AND id != 12

PHP

echo $row['plusTen']; //echos whatever balance was for this record + 10 added to it

Is this even possible?

I appreciate any suggestions.

SELECT *, balance+10 AS plusTen
FROM ...
etc...

you can create virtual fields in a WHERE clause, if you insist, but things in where clauses don't get returned to the client, because they simply act as filters. You need to actually create the virtual field in the field portion of the query, as above.

You need to include the additional field in the SELECT not the WHERE part of the statment, like so:

SELECT *,
    balance+10 AS plusTen
FROM bank
WHERE id != 12

To add more fields, just separate them with a comma after the SELECT part of the statement