Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Connecting DB tables

Connecting DB tables

Scheduled Pinned Locked Moved Database
questiondatabaseregexjson
10 Posts 5 Posters 2 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.
  • M Offline
    M Offline
    MekaC
    wrote on last edited by
    #1

    Hey :) Ive tried the INNER, LEFT, RIGHT join but it doesnt seem as if my tables are connecting. I have tables with different names and none match. I also have a main table(login/register) and want the rest to connect to that. How do I go about doing this? Thank ya :)

    D M M L 4 Replies Last reply
    0
    • M MekaC

      Hey :) Ive tried the INNER, LEFT, RIGHT join but it doesnt seem as if my tables are connecting. I have tables with different names and none match. I also have a main table(login/register) and want the rest to connect to that. How do I go about doing this? Thank ya :)

      D Offline
      D Offline
      David Mujica
      wrote on last edited by
      #2

      Post your SQL code and table definitions and you should get some help here.

      M 1 Reply Last reply
      0
      • M MekaC

        Hey :) Ive tried the INNER, LEFT, RIGHT join but it doesnt seem as if my tables are connecting. I have tables with different names and none match. I also have a main table(login/register) and want the rest to connect to that. How do I go about doing this? Thank ya :)

        M Offline
        M Offline
        Member_15329613
        wrote on last edited by
        #3

        MekaC wrote:

        How do I go about doing this?

        There is no way for anyone to tell you without seeing your tables. However, a generic answer is like this.

        SELECT table1.*, table2.* -- select everything from table1 and table2
        FROM table1
        INNER JOIN table2 ON table1.field1 = table2.field1 -- here you put what 2 columns (at least) match the tables.

        MekaC wrote:

        I have tables with different names and none match.

        If no tables match then you can't connect them with your login code, but why would you want to anyway? I don't think you are using the right words to expain youself.

        M 1 Reply Last reply
        0
        • M MekaC

          Hey :) Ive tried the INNER, LEFT, RIGHT join but it doesnt seem as if my tables are connecting. I have tables with different names and none match. I also have a main table(login/register) and want the rest to connect to that. How do I go about doing this? Thank ya :)

          M Offline
          M Offline
          MekaC
          wrote on last edited by
          #4

          Here are my tables :) :

          Table structure for table `categories`

          CREATE TABLE `categories` (
          `id` int(30) NOT NULL,
          `name` varchar(250) NOT NULL,
          `description` text NOT NULL,
          `date_updated` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
          ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;


          --
          -- Table structure for table `comments`

          CREATE TABLE `comments` (
          `id` int(30) NOT NULL,
          `topic_id` int(30) NOT NULL,
          `user_id` int(30) NOT NULL,
          `comment` text NOT NULL,
          `date_created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
          `date_updated` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
          ) ENGINE=InnoDB DEFAULT CHARSET=utf8;


          --
          -- Table structure for table `forum_views`

          CREATE TABLE `forum_views` (
          `id` int(30) NOT NULL,
          `topic_id` int(30) NOT NULL,
          `user_id` int(30) NOT NULL
          ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;


          --
          -- Table structure for table `friendship`

          CREATE TABLE `friendship` (
          `friend_id` int(11) NOT NULL,
          `receiver` varchar(30) NOT NULL,
          `sender` varchar(30) NOT NULL
          ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC;


          --
          -- Table structure for table `member`

          CREATE TABLE `member` (
          `member_id` int(11) NOT NULL,
          `username` varchar(30) NOT NULL,
          `email` varchar(30) NOT NULL,
          `sex` varchar(100) NOT NULL,
          `password` varchar(30) NOT NULL,
          `day` varchar(100) NOT NULL,
          `month` varchar(30) NOT NULL,
          `year` varchar(100) NOT NULL
          ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC;


          --
          -- Table structure for table `messages`

          CREATE TABLE `messages` (
          `messageid` int(11) NOT NULL,
          `sender_id` int(11) NOT NULL,
          `receiver_id` int(11) NOT NULL,
          `message` varchar(5000) NOT NULL,
          `date` date NOT NULL
          ) ENGINE=InnoDB DEFAULT CHARSET=latin1;


          --
          -- Table structure for table `myfriends`

          CREATE TABLE `myfriends` (
          `friend_id` int(11) NOT NULL,
          `myid` varchar(30) NOT NULL,
          `myfriends` varchar(30) NOT NULL
          ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC;


          --

          L C 2 Replies Last reply
          0
          • D David Mujica

            Post your SQL code and table definitions and you should get some help here.

            M Offline
            M Offline
            MekaC
            wrote on last edited by
            #5

            Hey there I just posted my tables!!

            1 Reply Last reply
            0
            • M Member_15329613

              MekaC wrote:

              How do I go about doing this?

              There is no way for anyone to tell you without seeing your tables. However, a generic answer is like this.

              SELECT table1.*, table2.* -- select everything from table1 and table2
              FROM table1
              INNER JOIN table2 ON table1.field1 = table2.field1 -- here you put what 2 columns (at least) match the tables.

              MekaC wrote:

              I have tables with different names and none match.

              If no tables match then you can't connect them with your login code, but why would you want to anyway? I don't think you are using the right words to expain youself.

              M Offline
              M Offline
              MekaC
              wrote on last edited by
              #6

              Hey there I just posted my tables!!

              M 1 Reply Last reply
              0
              • M MekaC

                Here are my tables :) :

                Table structure for table `categories`

                CREATE TABLE `categories` (
                `id` int(30) NOT NULL,
                `name` varchar(250) NOT NULL,
                `description` text NOT NULL,
                `date_updated` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;


                --
                -- Table structure for table `comments`

                CREATE TABLE `comments` (
                `id` int(30) NOT NULL,
                `topic_id` int(30) NOT NULL,
                `user_id` int(30) NOT NULL,
                `comment` text NOT NULL,
                `date_created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
                `date_updated` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;


                --
                -- Table structure for table `forum_views`

                CREATE TABLE `forum_views` (
                `id` int(30) NOT NULL,
                `topic_id` int(30) NOT NULL,
                `user_id` int(30) NOT NULL
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;


                --
                -- Table structure for table `friendship`

                CREATE TABLE `friendship` (
                `friend_id` int(11) NOT NULL,
                `receiver` varchar(30) NOT NULL,
                `sender` varchar(30) NOT NULL
                ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC;


                --
                -- Table structure for table `member`

                CREATE TABLE `member` (
                `member_id` int(11) NOT NULL,
                `username` varchar(30) NOT NULL,
                `email` varchar(30) NOT NULL,
                `sex` varchar(100) NOT NULL,
                `password` varchar(30) NOT NULL,
                `day` varchar(100) NOT NULL,
                `month` varchar(30) NOT NULL,
                `year` varchar(100) NOT NULL
                ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC;


                --
                -- Table structure for table `messages`

                CREATE TABLE `messages` (
                `messageid` int(11) NOT NULL,
                `sender_id` int(11) NOT NULL,
                `receiver_id` int(11) NOT NULL,
                `message` varchar(5000) NOT NULL,
                `date` date NOT NULL
                ) ENGINE=InnoDB DEFAULT CHARSET=latin1;


                --
                -- Table structure for table `myfriends`

                CREATE TABLE `myfriends` (
                `friend_id` int(11) NOT NULL,
                `myid` varchar(30) NOT NULL,
                `myfriends` varchar(30) NOT NULL
                ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC;


                --

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                Please remove all that hexdump which serves no purpose.

                1 Reply Last reply
                0
                • M MekaC

                  Here are my tables :) :

                  Table structure for table `categories`

                  CREATE TABLE `categories` (
                  `id` int(30) NOT NULL,
                  `name` varchar(250) NOT NULL,
                  `description` text NOT NULL,
                  `date_updated` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
                  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;


                  --
                  -- Table structure for table `comments`

                  CREATE TABLE `comments` (
                  `id` int(30) NOT NULL,
                  `topic_id` int(30) NOT NULL,
                  `user_id` int(30) NOT NULL,
                  `comment` text NOT NULL,
                  `date_created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
                  `date_updated` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
                  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;


                  --
                  -- Table structure for table `forum_views`

                  CREATE TABLE `forum_views` (
                  `id` int(30) NOT NULL,
                  `topic_id` int(30) NOT NULL,
                  `user_id` int(30) NOT NULL
                  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;


                  --
                  -- Table structure for table `friendship`

                  CREATE TABLE `friendship` (
                  `friend_id` int(11) NOT NULL,
                  `receiver` varchar(30) NOT NULL,
                  `sender` varchar(30) NOT NULL
                  ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC;


                  --
                  -- Table structure for table `member`

                  CREATE TABLE `member` (
                  `member_id` int(11) NOT NULL,
                  `username` varchar(30) NOT NULL,
                  `email` varchar(30) NOT NULL,
                  `sex` varchar(100) NOT NULL,
                  `password` varchar(30) NOT NULL,
                  `day` varchar(100) NOT NULL,
                  `month` varchar(30) NOT NULL,
                  `year` varchar(100) NOT NULL
                  ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC;


                  --
                  -- Table structure for table `messages`

                  CREATE TABLE `messages` (
                  `messageid` int(11) NOT NULL,
                  `sender_id` int(11) NOT NULL,
                  `receiver_id` int(11) NOT NULL,
                  `message` varchar(5000) NOT NULL,
                  `date` date NOT NULL
                  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;


                  --
                  -- Table structure for table `myfriends`

                  CREATE TABLE `myfriends` (
                  `friend_id` int(11) NOT NULL,
                  `myid` varchar(30) NOT NULL,
                  `myfriends` varchar(30) NOT NULL
                  ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC;


                  --

                  C Offline
                  C Offline
                  CHill60
                  wrote on last edited by
                  #8

                  I have edited this post to remove the hex dump of the image - it made the thing impossible to read. Having given us your table structures how are they meant to link together? And what are you trying to link? Try sharing just one of your queries that doesn't work so at least we've got something to start on

                  1 Reply Last reply
                  0
                  • M MekaC

                    Hey there I just posted my tables!!

                    M Offline
                    M Offline
                    Member_15329613
                    wrote on last edited by
                    #9

                    OK, but what is the question now?

                    1 Reply Last reply
                    0
                    • M MekaC

                      Hey :) Ive tried the INNER, LEFT, RIGHT join but it doesnt seem as if my tables are connecting. I have tables with different names and none match. I also have a main table(login/register) and want the rest to connect to that. How do I go about doing this? Thank ya :)

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #10

                      They're called relations. Please say you don't do medical equipment.

                      Bastard Programmer from Hell :suss: "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups