-1
CREATE TABLE Patient (
  Patient_id INT PRIMARY KEY,
  First_name VARCHAR(20),
  Last_name VARCHAR(20),
  Age INT,
  Registration_date DATE,
  Sex VARCHAR(1),
  Adress VARCHAR(25),
  Blood_group VARCHAR(5),
  Doctor_id INT,
  Branch_id INT
 );

This is my table

INSERT INTO Patient VALUES (600, 'Hasib' , 'Ahmad' , 24 , 2019-09-17 ,'M', '187,Mainland', 'B +ve',NULL,NULL);

This is my insertion but I am getting error showing ER_WRONG_VALUE_COUNT_ON_ROW: Column count doesn't match value count at row 1. Help me get rid of it.

GMB
  • 216,147
  • 25
  • 84
  • 135

2 Answers2

1

You must give the date as string like : '2019-09-17'

change your query to:

INSERT INTO Patient VALUES (600, 'Hasib' , 'Ahmad' , 24 , '2019-09-17' ,'M', '187,Mainland', 'B +ve',NULL,NULL);
Bernd Buffen
  • 14,525
  • 2
  • 24
  • 39
0

The date needs to be surrounded with single quotes.

Also, you should enumerate all the columns that you want to insert to; that's a good practice in SQL coding, and it makes it easier to backtrack what is happening when things go wrong. Since you are inserting NULL values in the last two columns, so I removed them from the query.

INSERT INTO Patient (
    Patient_ID, 
    First_Name, 
    Last_Name, 
    Age, 
    Registration_date, 
    Sex, 
    Address, 
    Blood_group
)
VALUES (
    600, 
    'Hasib', 
    'Ahmad', 
    24,
    '2019-09-17',
    'M',
    '187,Mainland', 
    'B +ve'
);
GMB
  • 216,147
  • 25
  • 84
  • 135