Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Relation btween tables
Forum Updated to NodeBB v4.3 + New Features

Relation btween tables

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 894 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    yakine
    wrote on last edited by
    #1

    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 error

    Can't create table 'test.cd' (errno: 150) QMYSQL: Unable to execute query
    please help me

    IF YOU HAVE MERCY ON PEOPLE GOD HAVE MERCY ON YOU

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • Y Offline
        Y Offline
        yakine
        wrote on last edited by
        #3

        thank you chris kawa it's work

        IF YOU HAVE MERCY ON PEOPLE GOD HAVE MERCY ON YOU

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved