如何在mysql中将得分查询搜索从1列扩展到3列? [英] How do I expand a score query search from 1 column to 3 columns in mysql?

查看:80
本文介绍了如何在mysql中将得分查询搜索从1列扩展到3列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在下面列出了一个工作搜索,它给出了游戏1的最低分数,该分数位于名为Gm1的列中。

还有两个名为Gm2和Gm3的列。



想扩大我的搜索范围,在一次类似搜索中从Gm1或Gm2或Gm3给出最小游戏。

ie

搜索所有3列得分最低。



我使用2012年前的mysql

提前致谢。



我尝试过:



I have a working search listed below that gives a Min score for game 1 which is in column named Gm1.
Have two more columns named Gm2 and Gm3.

Would like to expand my search to give min game from Gm1 or Gm2 or Gm3 in one similar search.
ie
Search all 3 columns to give lowest score.

I am using pre 2012 mysql
Thanks in advance.

What I have tried:

 /* Min value for 3 Game Scratch   */
FORMAT ((SELECT MIN(Gm1) 
         	FROM b_Scores L 
         		WHERE L.Bowler = R.Bowler 
         		AND L.Date <= R.Date),0) as "Min Gm1",

推荐答案

尝试临时表:
create temporary table if not exists temp_table select min(game1) min_score from score;
insert into temp_table select min(game2) from score;
insert into temp_table select min(game3) from score;
select min(min_score) lowest_score from temp_table;

但是,如果您首先更有效地设计了数据库,那么可以避免这种跨列查询的麻烦。

However, If can avoid the hassle of such cross-column queries if you have designed your database more efficiently in the first place.


这篇关于如何在mysql中将得分查询搜索从1列扩展到3列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆