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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:15:09+00:00 2026-06-06T13:15:09+00:00

I have a visitor table that looks like this: VID Name Address DOB 001

  • 0

I have a visitor table that looks like this:

VID    Name      Address        DOB
001    Bob       101 St         03/05/2001
002    James     505 Rd         02/06/1985
003    Jill      201 Place      04/06/1970

And a visits table that looks like this:

VID    Date          Reason
001    05/07/2012    Family
001    06/01/2012    Family
003    03/02/2011    Other

I want to do a join query between these two on VID (which I already did) but also have the query show all (multiple) results from visits. So the results would look like:

Name         DOB              Visits
Bob          03/05/2001       05/07/2012 Family, 06/01/2012 Family
James        02/06/1985
Jill         04/06/1970       03/02/2011 Other

Is this possible? I attempted a subquery like:

SELECT Name, DOB, (SELECT Date, Reason FROM visits AS H WHERE H.VID=visitor.VID) As Visits FROM visitor;

But that gave me the obvious Subquery returned more than 1 value error. The data would be parsed by PHP, but I was hoping to accomplish this in one query.

  • 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-06T13:15:11+00:00Added an answer on June 6, 2026 at 1:15 pm

    You can use a FOR XML PATH construct to concatenate your results into one column

    SELECT   Name
             , DOB
             , STUFF((SELECT ', ' 
                             + CONVERT(VARCHAR(16), H.Date, 101)
                             + ' ' 
                             + H.Reason 
                      FROM   visits AS H 
                      WHERE  H.VID = visitor.VID 
                      FOR XML PATH('')), 1, 2, '')
    FROM     visitor;
    

    Note that various date formats are supported with convert. I have used 101 in the example wich translates to mm/dd/yyyy.

    Have a look at MSDN for all styles supported by convert.

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

Sidebar

Related Questions

I have a mysql table that looks something like this: Row 1: 'visitor_input_id' =>
My table looks like this: ID NAME VALUE 1 home San Jose 1 visitor
I have a table named visiting that looks like this: id | visitor_id |
I have a scenario that looks like this: User A is a registered user.
I have this table pageview id | visitor | id_realestate | time ----------------------------------------------- I
Hello and sorry for my bad english! I have a table like this: <table
I have a table that has the following columns: GRVLID GRID Timein Timeout This
I have following table structure there is column vid in that i want entry
I have code that redirects visitor to login -page via authentication provider selector -page
I have a jQuery colorpicker that the visitor can change and I am trying

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.