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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:44:42+00:00 2026-05-23T07:44:42+00:00

Consider the following structure DB structure. Current working language is Coldfusion and MSSQL. Tables

  • 0

Consider the following structure DB structure. Current working language is Coldfusion and MSSQL.

Tables
Hotels: - Columns - hotelid, name, company, address, state, city, zip
Media: - Columns - mediaid, label, url
HotelsXMedia: - Columns - xid, hotelid, mediaid

Basically we have a table with hotels and a table that contains images and a cross table to handle the many to many relationship. Desired output is a single array (or query), with each item having all of the columns from the hotels table as well as the all of the rows of it’s media table inside the primary row so it can be passed on to a theming function, for example.

Current Method is to query hotels, convert to array, extract hotelids from result set. Query media based on hotelid. Convert resulting media query into structure where the index is the hotelid. Then loop over the hotels array and assign in it’s media data into the hotels array. Then pass the hotels array on to wherever it needs to go.

Is there a more efficient way of doing this? Is there a way of doing this without doing two SQL queries and all of the resulting folding and looping. Nearly every module in the application utilizes the media table to store it’s images so for nearly every component on the page we have to perform this sort of combination and it seems quite cumbersome. Is there no better way? In addition, while it may only provide a slight benefit to enhance this one to many query combination, because it’s neccessary in 90% of the components, the enhancement benefit would spread to all of them thus resulting in decent gains.

I would consider it a feasible solution if a column in the result query was a delimited list of joined MEDIA urls. But unfortunately in MSSQL we don’t have group_concat(). If this method was done is there an easy way to grab multiple columns, if for example I wanted to grab the media:url and media:label? Is there a way to ensure that empty or null values still get a delimiter if a record in the media table has a url but lacks a label thus causing the 2 lists to be out of alignment. If I went this route would I have to do multiple for XML paths in order to get there? Any guidance would be greatly appreciated.

  • 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-23T07:44:43+00:00Added an answer on May 23, 2026 at 7:44 am

    Check out Simulating group_concat MySQL function in Microsoft SQL Server 2005?

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

Sidebar

Related Questions

Consider i have 4 workbooks with the following structure... 1. Main.xlsx Name Jan Feb
Consider following tables structure: users (user_id, ...) images (image_id, user_id, ...) tag_links (tag_id, image_id)
Consider the following table structure: id name rank position ------------------------------- 1 Steve 5 0
Consider the following directory structure: ROOT ------ images ............... logo.png ------ includes ............... vars.php
Consider the following data structure: List<Person> People; class Person { List<Car> Cars; List<Hobby> Hobbies;
Consider the following subversion directory structure /dir1/file.txt /dir2/file.txt I want to move the file.txt
Consider the following structure : alt text http://aeon-dev.org/pap/pap_db.png Ignore the table user_token. Now, imagine
Consider the following directory structure: ./source/com/mypackage/../A.java ./extensions/extension1/source/com/mypackage/../T.java ./extensions/extension2/source/com/mypackage/../U.java ... ./extensions/extensionN/source/com/mypackage/../Z.java I want to produce
Consider the following class structure: class Filter { virtual void filter() = 0; virtual
Consider following tables in MySQL database: entries: creator_id INT entry TEXT is_expired BOOL other:

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.