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 9164457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:41:18+00:00 2026-06-17T14:41:18+00:00

I have the following query against my mysql database. SELECT mn.id, mn.created_date, mn.created_by, mnt.description,

  • 0

I have the following query against my mysql database.

SELECT
  mn.id,
  mn.created_date,
  mn.created_by,
  mnt.description,
  u.handle,
  mn.admin_request_company_id
FROM member_notification mn,
  member_notification_type mnt,
  member m,
  user u
WHERE mn.member_notification_type_id = mnt.id
    AND mnt.name = 'COMPANYVALIDATION'
    AND mn.created_by = m.id
    AND m.user_id = u.id;

This is working fine however I now need to extend this to go get a company name off another table. The problem is that to do that I need to re-join against the member table using the key
mn.admin_request_company_id, however I’m not sure how to go about this.

I’ve tried creating a member m2 table but I’m getting errors. What I’m trying to achieve is something along the lines of the following pseudo code:

SELECT
  mn.id,
  mn.created_date,
  mn.created_by,
  mnt.description,
  u.handle,
  mn.admin_request_company_id,
  /*c.company_name*/
FROM member_notification mn,
  member_notification_type mnt,
  member m,
  /*member m2,*/
  /*company c,*/
  /*user u*/
WHERE mn.member_notification_type_id = mnt.id
    AND mnt.name = 'COMPANYVALIDATION'
    AND mn.created_by = m.id
    AND m.user_id = u.id
   /* AND mn.admin_request_company_id = m2.company_id
    AND m2.company_id = c.id*/

edit
Table structures as are follows:

CREATE TABLE member_notification (
id INT NOT NULL AUTO_INCREMENT,
item_id INT NULL,
member_id INT NULL,
text VARCHAR(1) NOT NULL,
member_notification_type_id INT NULL,
marked_read VARCHAR(1) NOT NULL,
created_date DATETIME NOT NULL,
created_by VARCHAR(50) NOT NULL,
admin_request_company_id INT NULL,
PRIMARY KEY (id)
) ENGINE=innodb;

CREATE TABLE member_notification_type (
id INT NOT NULL AUTO_INCREMENT,
name VARCHAR(20) NOT NULL,
description VARCHAR(50) NULL,
PRIMARY KEY (id)
) ENGINE=innodb;

CREATE TABLE member (
id INT NOT NULL AUTO_INCREMENT,
user_id INT NULL,
company_id INT NULL,
soft_delete VARCHAR(10) DEFAULT 'N',
member_status_id INT NOT NULL,
PRIMARY KEY (id)
) ENGINE=innodb;


CREATE TABLE user (
id INT NOT NULL AUTO_INCREMENT,
handle VARCHAR(50) NOT NULL,
first_name VARCHAR(50) NOT NULL,
last_name VARCHAR(50) NOT NULL,
date_of_birth VARCHAR(50) NULL,
soft_delete VARCHAR(10) DEFAULT 'N',
PRIMARY KEY (id)
) ENGINE=innodb;

CREATE TABLE company (
id INT NOT NULL AUTO_INCREMENT,
owning_company_id INT NULL,
company_type_id INT NULL,
name VARCHAR(50) NOT NULL,
company_details_id INT NULL,
PRIMARY KEY (id)
) ENGINE=innodb;
  • 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-06-17T14:41:19+00:00Added an answer on June 17, 2026 at 2:41 pm

    It seems like you just want to use the following which just adds a second join to the member table:

    SELECT
      mn.id,
      mn.created_date,
      mn.created_by,
      mnt.description,
      u.handle,
      mn.admin_request_company_id,
      c.name
    FROM member_notification mn
    INNER JOIN member_notification_type mnt
      on mn.member_notification_type_id = mnt.id
    INNER JOIN member m1
      on mn.created_by = m1.id
    INNER JOIN user u
      on m1.user_id = u.id
    INNER JOIN member m2
      on mn.admin_request_company_id = m2.company_id
    INNER JOIN company c
      on m2.company_id = c.id
    WHERE mnt.name = 'COMPANYVALIDATION'
    

    Notice, I changed your current joins in the WHERE clause to ANSI join syntax. I also used an INNER JOIN between the tables, you might need to use a LEFT JOIN.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following query running against a mysql database: select value from fact_data
I have the following MySQL query: SELECT title, description FROM some_table WHERE MATCH (title,description)
I have the following query to select users and their locations, etc from MySQL
I have the following query running against a MySQL db every 30 seconds: SELECT
I have following query: $query=SELECT language_value, votes, user_id FROM labels WHERE approved=1 AND label_value=.
I have following query , select * from process where name like 'abc'; now
I have following query and data saved in a MySQL database with a timestamp
I have following SQL query SELECT TOP 10000 AVG(DailyNodeAvailability.Availability) AS AVERAGE_of_Availability FROM Nodes INNER
I have the following query: SELECT item.`ID`, item.`Name`, item.`UnitCost`, item.`Price`, discount.`rate` FROM item INNER
I have the following query SELECT * FROM `articles` WHERE ( ( UCASE( `title`

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.