Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6918005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:48:13+00:00 2026-05-27T09:48:13+00:00

I have 2 tables: pages and menu I want to have a pointer into

  • 0

I have 2 tables: pages and menu

I want to have a pointer into menu table as foreign key to pages.id.
The problem is that some menu rows don’t have a link to page.
When someone clicks in the link opens a submenu.
How i do this in phpmyadmin?

The match i want is 1 to 1 or 1 to 0

Thanks

Maybe if i have a row to pages that has id=some_id with pages.body=null
and all the menus that i want to have no submenu would have menu.pages_id=some_id
Is this the right way to do that i want?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T09:48:14+00:00Added an answer on May 27, 2026 at 9:48 am

    Using some magic value for menu.pages_id doesn’t work because that value whatever it is must exist on some row in the pages table.

    The right way to do this is to make menu.pages_id accept NULL. It’s legal for a column to be nullable even if it’s part of a UNIQUE constraint and a FOREIGN KEY constraint.

    CREATE TABLE menu (
      ...
      pages_id INT NULL,
      UNIQUE KEY (pages_id),
      FOREIGN KEY (pages_id) REFERENCES pages(pages_id)
    ) ENGINE=InnoDB;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

On my pages I have a table with rows that typically look like this:
It is advisable to use tables in HTML pages (now that we have CSS)?
I have a Pages table that stores all my view urls and this table
I want to place a table on my page. I have two tables in
I want to join a pages table and menu table. CREATE TABLE IF NOT
I have a Pages table, I have a PagesRoles table with PageId, RoleID that
I have a problem with include pages in PHP. Picture shows what I want
I have a table of pages in my database, each page can have a
I have long tables generated by datagrid control that go beyond the page width.
I have a problem as i've described in title. I've got menu and I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.