【问题标题】:sql unable to insertsql无法插入
【发布时间】:2022-01-10 18:31:56
【问题描述】:

我试图向表中插入一些数据,mysql 给出了语法错误,我找不到,请我帮忙

INSERT INTO museums(id,name,rate,phone,opening_hours,closing_hours,location,image)
VALUES(1,"The Royal Automobile Museum",4.7,065411392,10:00:00, 7:00:00,"At Tibbiyya, Amman",LOAD_FILE('C:\xampp\htdocs\wael\images\The Royal Automobile Museum.jpg'));
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ':00:00, 7:00:00,"At Tibbiyya, Amman",LOAD_FILE('C:\xampp\htdocs\wael\images\T...' at line 2

【问题讨论】:

标签: mysql sql mariadb


【解决方案1】:

试试这个:

INSERT INTO museums (id,name,rate,phone,opening_hours,closing_hours,location,image) VALUES (1,'The Royal Automobile Museum',4.7,065411392,'10:00:00','7:00:00','At Tibbiyya, Amman','LOAD_FILE(''C:\xampp\htdocs\wael\images\The Royal Automobile Museum.jpg'')');

它给出的错误可能是由于 C:/// 之前和 jpg 之后的 ' 标记。所以你需要把它改成 '' 而不是 '

【讨论】:

    【解决方案2】:

    使用 ' 表示小时和电话

    insert into museums
        (
           id
         , name
         , rate
         , phone
         , opening_hours
         , closing_hours
         , location
         , image
        )
        values
        (1
        , 'The Royal Automobile Museum'
        , 4.7
        , '065411392'
        , '10:00:00'
        , '7:00:00'
        , 'At Tibbiyya, Amman'
        , LOAD_FILE('C:\xampp\htdocs\wael\images\The Royal Automobile Museum.jpg'))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-10-31
      • 2014-03-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多