Skip to content Skip to sidebar Skip to footer

Incorrect Syntax Near The Keyword 'JOIN'. Using Asp.net

Kindly help me on identifying the cause of this error Incorrect syntax near the keyword 'JOIN' Here is the code: Label name = (Label)GuitarBrandsGridView.Rows[e.RowIndex].FindCo

Solution 1:

Here is the right to do delete from join syntax

DELETE S  --missing alias name
FROM stringInstrumentItem S 
JOIN brand B 
  ON S.brandId = B.brandId 
WHERE B.name = @brand

Note : You don't need the sub-query, since Brand table is already joined


Solution 2:

change this:

DELETE FROM stringInstrumentItem JOIN brand ON stringInstrumentItem.brandId = brand.brandId WHERE stringInstrumentItem.brandId IN(SELECT brand.brandId FROM brand WHERE name = @brand)

to this:

DELETE FROM stringInstrumentItem
FROM stringInstrumentItem t1 JOIN brand t2 ON t1brandId = t2.brandId WHERE t1.brandId IN(SELECT t3.brandId FROM brand t3 WHERE name = @brand)

Hope I help you :)


Solution 3:

You have to give the table you want to delete an alias. I just named the table "sII". Furthermore you don't need an WHERE-clause. You could restrict the delete in the join-conditions too.

   DELETE sII
     FROM stringInstrumentItem  sII
INNER JOIN brand b
        ON sII.brandId = b.brandId 
       AND b.name = @brand

Post a Comment for "Incorrect Syntax Near The Keyword 'JOIN'. Using Asp.net"