Insert into a table which has a dash in the name

前端 未结 4 1941
误落风尘
误落风尘 2020-12-07 02:06

I have a table called concept-relation and I want to insert into it.

for ($i = 0; $i < count($sources); $i++) {
    $sourceID = $this->get         


        
相关标签:
4条回答
  • 2020-12-07 02:22
    $query2 = "INSERT INTO `concept-relation` (relationID, firstConceptID, secondConceptID)
                    VALUES (:rID, :sID, :dID)";
    
    0 讨论(0)
  • 2020-12-07 02:22

    Try:

    "INSERT INTO `concept-relation` (relationID, firstConceptID, secondConceptID) VALUES (:rID, :sID, :dID)";
    
    0 讨论(0)
  • 2020-12-07 02:40

    try this

    $query2 = "INSERT INTO concept-relation (relationID, firstConceptID, secondConceptID)
                    VALUES (:rID, :sID, :dID)";
    
    0 讨论(0)
  • 2020-12-07 02:41

    Enclosing identifiers with backtick makes reserved words/characters as valid identifiers in mysql.

    So you should use

     `concept-relation`
    

    The backtick (`)is the key at the top-left of this keyboard.

    enter image description here

    0 讨论(0)
提交回复
热议问题