Home > Blockchain >  Solution MYSQL database query INSERT
Solution MYSQL database query INSERT

Time:01-30

I want to insert data in to a mysql database table caled furesz. What do I need to add to my query so that I can insert 'M-001' in to the machine column?

so far I have come with My code:

INSERT INTO furesz (wood, cubic, width, machine) 
SELECT wood, cubic, width
FROM kobolo
WHERE wood = 'oak' AND width = '0.30' AND length = '0.12'

Result:

machine wood cubic width
oak 0.12 0.30

CodePudding user response:

If it is a fix value, you can simply add it to the query:

INSERT INTO furesz (wood, cubic, width, machine) 
SELECT wood, cubic, width, 'M-001'
FROM kobolo
WHERE wood = 'oak' AND width = '0.30' AND length = '0.12'

CodePudding user response:

try it:

INSERT INTO furesz (wood, cubic, width, machine) 
    SELECT 'oak', cubic, '0.30', 'M-001'
    FROM kobolo
    WHERE wood = 'oak' AND width = '0.30' AND length = '0.12'
  •  Tags:  
  • Related