sql - mysql error #1064 -


i keep getting error code #1064 when trying create products table code im tryng use

  create table products ( prod_id int not null, prod_name character(20) not null, price decimal(19, 4), on_hand int, supp_id int, primary key (prod_id), foreign key (supp_id) ); 

if tell me doing wrong and/or give me solution work appreciated

thanks

you need add table foreign key references. below if table containing supp_id called supptable , had referencing key supp_id.

edit: updated reflect referencing table being suppliers supp_id referencing column. note supp_id on suppliers must int work , should primary key of referencing table (or have index created column).

create table products (     prod_id int not null,     prod_name character(20) not null,     price decimal(19, 4),     on_hand int,     supp_id int,     primary key (prod_id),     foreign key (supp_id) references suppliers(supp_id) ); 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -