MySQL error: can’t create table ‘..’( errno:150 )Solutions

scenario
Student table S (SNO, SNAME, SAGE), class schedule C (CNO, CNAME)
When the course selection table (SC) is created, set (SNO, CNO) as the primary key and SNO and CNO as the foreign keys

drop table if exists sc1;
create table sc1(
    sno varchar(10),
    cno varchar(10),
    grade numeric,
    primary key(sno,cno),
    foreign key(sno) references s(sno),
    foreign key(cno) references c(cno)
);

Error warning:

The solution
1. Check whether the types and sizes of foreign key fields in SC table are exactly the same as those in S table C table
2. One of the foreign keys you are trying to reference has no index or is not a primary key. If one of the foreign keys is not a primary key, you must create an index for it.
3, one or two tables are MyISAM engine table, if you want to use foreign key constraints, must be InnoDB engine

The error of the author is that cNO is not set as primary key in Table C, which can be solved by setting it once

Read More: