Query Required

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
suleman
Forum Newbie
Posts: 3
Joined: Sat Oct 30, 2010 3:07 am

Query Required

Post by suleman »

i require query for following scenario
I have two table
table1 have following columns
person_id
Name
gender

and has 1 record
person_id Name gender
1 Robert Male

and table2 has following column

person_id
result1

and has following 3 rows

person_id result
1 php1
1 php2
1 php3


I need query for displaying result like this

Robert male php1 php2 php3
User avatar
DigitalMind
Forum Contributor
Posts: 152
Joined: Mon Sep 27, 2010 2:27 am
Location: Ukraine, Kharkov

Re: Query Required

Post by DigitalMind »

that's impossible
mikosiko
Forum Regular
Posts: 757
Joined: Wed Jan 13, 2010 7:22 pm

Re: Query Required

Post by mikosiko »

DigitalMind wrote:that's impossible
psssht.... :wink: GROUP_CONCAT :wink:
User avatar
DigitalMind
Forum Contributor
Posts: 152
Joined: Mon Sep 27, 2010 2:27 am
Location: Ukraine, Kharkov

Re: Query Required

Post by DigitalMind »

mikosiko wrote: GROUP_CONCAT
yes, if we want to output it as a single field.
you're right :)
probably i misunderstood the question. i thought it needs to output result as separate fields :) it was sunday's midnight... :)
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Query Required

Post by VladSun »

If there are always 3 rows () in person_id result, then one could create some kind of a cross-table query ... but only and if only there are always 3 rows in person_id result. Which on the other hand sounds like a redundant "db normalization".
There are 10 types of people in this world, those who understand binary and those who don't
Post Reply