MySQL php - adding three datas and order by
OK so let's say I have three fields called "mines, explodes, and tags" in a table. I want to add those three together and say they are the "kills" ad开发者_StackOverflow社区ded up from the 3 fields and order them from highest to lowest (DESC). Is that possible?
Yes that will work! (But it won't be efficient.)
SELECT *, mines + explodes + tags AS kills
FROM your_table
ORDER BY kills DESC
If performance is a concern you should store the total as a column in the table and add an index to that column so that order by can use this index.
精彩评论