带有十六进制函数的sqlite语法错误

时间:2017-12-31 01:20:36

标签: sqlite

我想选择下面表格X的第一行,并将“name”列更新为“53656C696E613333”,如下所示。 Sqlite一直在说语法错误。有人可以帮忙解决这个问题吗?非常感谢!

function findSelectedMap(mapID, cb) {
    $.getJSON('maps.json', function (json) {
        json.forEach(function (entry) {
            if (entry.maps.id == mapID) {
                changeLayerTo = entry.maps.url;
                maxZoom = entry.maps.zoom;
            }  // end if
        }); // end json.forEach

        cb();
    });    // end $.getJSON
}       // end findSelectedMap

function overlaySelector() {
    $("#select-overlay").change(function () {
        mapID = $("#select-overlay input[type='radio']:checked").val();
        findSelectedMap(mapID, function() {
            currentLayer = L.tileLayer(changeLayerTo).addTo(map);
        }); // using mapID, find the url, zoom for overlayMap selected            
        // more map stuff
    }); // end $( "#select-overlay" ).  
} // end overlaySelector function

1 个答案:

答案 0 :(得分:1)

我想你可能想要这样的东西: -

UPDATE Ages 
    SET name = '53656C696E613333' 
    WHERE name = (SELECT name FROM Ages ORDER BY hex(name||age) LIMIT(1))
        AND age = (SELECT age FROM Ages ORDER BY hex(name||age) LIMIT(1))
;

代替: -

SELECT hex (name||age) AS X FROM Ages ORDER BY X

SELECT * FROM X LIMIT 1
UPDATE X SET name = '53656C696E613333'

这将导致: -

enter image description here

但是,由于您尚未为表格指定WITHOUT ROWID,因此您可以使用更简单的方法: -

UPDATE Ages 
    SET name = '53656C696E613333' 
    WHERE rowid = (SELECT rowid FROM Ages ORDER BY hex(name||age) LIMIT(1))
;