Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Relation btween tables
-
hello this my code
@if((query.exec("CREATE TABLE artist ( id INTEGER PRIMARY KEY,name VARCHAR(40) NOT NULL,country VARCHAR(40))"))&&(query.exec("CREATE TABLE cd ( id INTEGER PRIMARY KEY,title VARCHAR(40) NOT NULL,artistid INTEGER NOT NULL,year INTEGER NOT NULL,FOREIGN KEY (artistid) REFERENCES artist)")))@
am trying to create to tables and relation btween but i have this errorCan't create table 'test.cd' (errno: 150) QMYSQL: Unable to execute query
please help me
-
My SQL is a little rusty but shouldn't it be something like this?
@...FOREIGN KEY (artistid) REFERENCES artist(id)@
with the (id) at the end.
-
thank you chris kawa it's work