select max(imagefileid) imagefileid from docimagefile where docid=? group by id order by imagefileid desc 只查 isextfile 为空的数据
时间: 2024-01-17 10:03:32 浏览: 22
您可以使用以下 SQL 语句来实现:
```
SELECT MAX(imagefileid) AS imagefileid
FROM docimagefile
WHERE docid = ? AND isextfile IS NULL
GROUP BY id
ORDER BY imagefileid DESC
```
这将只查询 isextfile 为空的数据,并按照 imagefileid 的降序排列,然后选择最大的 imagefileid。
相关问题
select max(imagefileid) imagefileid from docimagefile where docid=? group by id order by imagefileid desc 只查 isextfile 为空或者为null的数据
您可以尝试以下 SQL 语句:
```
SELECT MAX(imagefileid) AS imagefileid
FROM docimagefile
WHERE docid=? AND (isextfile IS NULL OR isextfile='')
GROUP BY id
ORDER BY imagefileid DESC
```
这样可以筛选出 `isextfile` 为空或者为 null 的数据。请注意,这里我假设 `isextfile` 的数据类型为字符串类型,如果不是,请将 `''` 替换为对应类型的空值。
SELECT MAX(imagefileid) AS imagefileid FROM docimagefile WHERE docid=? AND docfiletype=12 GROUP BY id ORDER BY imagefileid DESC 改为 docfiletype = 3,6,7,12其中一个时使出
你的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。如果其他条件不变,可以直接使用上述查询语句,否则请根据实际情况进行修改。