我有一张车辆记录表,它有一个独特的号码牌,然后放置了记录的图像路径。
----------------------------------------------------------------------
| Number Plate | ImagePath
----------------------------------------------------------------------
TCZ9352 \folder\TCZ9352.pdf#
PCZ9353 \folder\\1-PB2CZ-2-PCZ9353.pdf#
我想进行查询,检查铭牌字段并查看它是否包含在imagepath名称中,以确保记录确实指向有效图像。
答案 0 :(得分:4)
对于MySQL,你可以使用它:
SELECT
number_plate,
imagepath,
CASE WHEN imagepath LIKE CONCAT('%', number_plate, '%')
THEN 'Yes'
ELSE 'No'
END AS is_contained
FROM
yourtable
对于Ms-Access:
SELECT
number_plate,
imagepath,
IIF(InStr(imagepath, number_plate)>0, 'Yes', 'No') AS is_contained
FROM yourtable
或者这只返回不包含字符串的行:
SELECT
number_plate,
imagepath
FROM
yourtable
WHERE
InStr(imagepath, number_plate)=0
答案 1 :(得分:0)
SELECT * FROM vehicle
WHERE imagepath NOT LIKE CONCAT('%', numberplate, '%')
;