Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/62.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
mysql使用列B和相关列C的最小值选择不同的列A_Mysql - Fatal编程技术网

mysql使用列B和相关列C的最小值选择不同的列A

mysql使用列B和相关列C的最小值选择不同的列A,mysql,Mysql,我有3列A和B。A列可能有具有相同ID的行,但ID具有不同的值。如何使用列B的最小值选择不同的列A,全部使用纯MySQL,不使用php?th 我很抱歉,因为我改变了问题,但这是为了澄清我自己。假设这是一张桌子: ColumnA ColumnB ColumnC a 1 car a 5 mouse b 6 key b 2 press b 4 enter

我有3列A和B。A列可能有具有相同ID的行,但ID具有不同的值。如何使用列B的最小值选择不同的列A,全部使用纯MySQL,不使用php?th

我很抱歉,因为我改变了问题,但这是为了澄清我自己。假设这是一张桌子:

ColumnA ColumnB ColumnC  

a       1       car    
a       5       mouse    
b       6       key  
b       2       press  
b       4       enter  
c       77      board  
c       22      check  
我预期的结果是:

ColumnA ColumnB ColumnC

a       1       car
b       2       press
c       22      check
你可以看看这把小提琴你可以看看这把小提琴
SELECT ColumnA, ColumnB, ColumnC
FROM table
WHERE ColumnB = (SELECT MIN(ColumnB) 
       FROM table AS t 
       WHERE t.ColumnA = table.ColumnA)