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

  • Home
  • SEARCH
  • 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 6224281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:38:39+00:00 2026-05-24T08:38:39+00:00

Here is my Database schema and the tables I am trying to link, I

  • 0

Here is my Database schema and the tables I am trying to link, I tried using a LEFT join but now it is creating a new result for each matched row.

https://i.stack.imgur.com/qItTW.png

I am currently building up my query and now trying to join these tables together (Procedure-> Procedure_event -> Resources -> Med_item)

In a scenario like this:

e.g. Procedure X has 3 rows procedure_events

I want the data returned to me in one record but with all the rows that make up that record.

However it is returning 3 rows of results like so:

  • Procedure X – procedure_event row 1
  • Procedure X – procedure_event row 2
  • Procedure X – procedure_event row 3

So the query result should be Procedure X – procedureevent rows 1,2,3

This is my code in Codeigniter PHP framework using Active Record:

$this->db->join('procedure_event', 'procedure.procedure_id = procedure_event.procedure_id' , 'left');

Thanks

  • 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-24T08:38:41+00:00Added an answer on May 24, 2026 at 8:38 am

    This is how LEFT JOIN works.

    So the query result should be Procedure X – procedureevent rows 1,2,3

    I think you need this: How do I get a count of associated rows in a left join in MySQL?

    MySQL can’t return two dimensional arrays, or merge rows. If you need all the “procedureevent rows 1,2,3” then just iterate through the result set, like you would normally do and add a small + icon that gets the procedureevents with AJAX.

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

Sidebar

Related Questions

Just getting into SQL stored queries right now... anyway, here's my database schema (simplified
I am trying to map a new domain model to a fixed-schema legacy database
The Media Wiki database Schema, here , has taught me a lot. Cannot-understand: In
Lets imagine I have the same database schema as here: http://www.databaseanswers.org/data_models/driving_school/index.htm If a customer
Here is my current setup: Database Role - MyDbRole Schema - MySchema User -
I am trying to map a legacy database here and I'm running into a
I'm using sphinx to list me some items from my database here. It's almost
Here is a simplified version of my database model. I have two tables: Image,
im trying to understand the process of creating tables in ruby-on-rails 3. i have
I am trying to restore a DB using an SQL script, but things foreign

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.