1)I want to insert Brand ID into Item table by using LEFT JOIN, below is the example code I tried to do , is it correct?
2)How to use INSERT SET with LEFT JOIN as I will get error message like this
select is not valid at this position, expecting EOF
INSERT INTO Brand SET Name="BMW" SELECT b.ID FROM Brand b LEFT JOIN Item i ON i.BrandID = b.ID Brand
| ID | Name |
|---|---|
| 1 | YSL |
| 2 | Gucci |
| 3 | Prada |
Item
| ID | BrandID | Name |
|---|---|---|
| 20 | 3 | Luxury bag |
| 21 | 2 | Earing |
Expected Result (The Brand ID is auto increment so I no need to insert it, and I know the item name being null is weird but I can't insert two table in one query.)
Brand
| ID | Name |
|---|---|
| 1 | YSL |
| 2 | Gucci |
| 3 | Prada |
| 4 | BMW |
Item
| ID | BrandID | Name |
|---|---|---|
| 20 | 3 | Luxury bag |
| 21 | 2 | Earing |
| 22 | 4 | null |