Get the App
SLTechnology News&Howtos  ›  Database  › 

Several database Sql statements

Shulou Source: shulou.com Published: 2022-06-01 07:22:43 10月03日 Update

(1) there may be tare weight records of multiple cars in the same table. I want to update the earliest record, that is, to update their tare weight. In sqlite3, it is as follows:

Update CarNoTable set TareWeight = '9080'-where CarNO=' Beijing A6390' and TareWeight =-(select TareWeight from CarNoTable where CarNo=' Beijing A6390'-order by TareTime limit 0men5)

CarNoTable: tabl

TareWeight: tare field

CarNo: car number

TareTime: tare weight time

(2) convert the string field to an integer to find the largest record. Like multiple tare records of a vehicle, you want to find out the largest record.

Select max (cast (TareWeight as FLOAT)) from CarNoTable where CarNo = 'Beijing A6390'

(3) check the maximum tare weight and time

Select CarNo, TareWeight,TareTime from CarNoTable where cast (TareWeight as FLOAT) in (select max (cast (TareWeight as FLOAT)) from CarNoTable where CarNo=' Beijing A00A01')

Tags: Tare weight maximum field time update multiple multiple character string integer car number vehicle data database statement Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft MySQL NVidia Huawei Shulou Tech Info