SELECT MAX(imagefileid) AS imagefileid FROM docimagefile WHERE docid=? AND docfiletype=12 GROUP BY id ORDER BY imagefileid DESC 改为 docfiletype = 3,6,7,12中任意一个即可
时间: 2024-02-17 17:04:02 浏览: 41
sql连接查询中,where关键字的位置讲解
你的SQL查询语句可以改为以下任意一种:
1. 当docfiletype等于3时,SQL查询语句为:
```
SELECT MAX(imagefileid) AS imagefileid
FROM docimagefile
WHERE docid=? AND docfiletype=3
GROUP BY id
ORDER BY imagefileid DESC
```
2. 当docfiletype等于6时,SQL查询语句为:
```
SELECT MAX(imagefileid) AS imagefileid
FROM docimagefile
WHERE docid=? AND docfiletype=6
GROUP BY id
ORDER BY imagefileid DESC
```
3. 当docfiletype等于7时,SQL查询语句为:
```
SELECT MAX(imagefileid) AS imagefileid
FROM docimagefile
WHERE docid=? AND docfiletype=7
GROUP BY id
ORDER BY imagefileid DESC
```
4. 当docfiletype等于12时,SQL查询语句为:
```
SELECT MAX(imagefileid) AS imagefileid
FROM docimagefile
WHERE docid=? AND docfiletype=12
GROUP BY id
ORDER BY imagefileid DESC
```
请注意,以上SQL查询语句只是将原来的docfiletype条件改为了3、6、7或12。如果其他条件不变,可以直接使用上述查询语句,否则请根据实际情况进行修改。另外,原始SQL语句中的GROUP BY条件应该是按id分组,而不是按docfileid分组,已经做了相应修改。
阅读全文