Reply to Re: Aligning multiple query results

Your name:

Reply:


Posted by Michael Austin on 01/10/06 01:49

kiqyou_vf wrote:

> Sorry, Google wouldn't let me post a reply. Here is the convo thus far:
>
> Jerry Stuckle wrote:
>
>>kiqyou_vf wrote:
>>
>>>I'm trying to pull data from 2 different tables and do a loop to
>>>retrieve more than one row. I'm having problems with aligning the
>>>information. Can someone lead me in the right direction? I've done some
>>>looking myself and found something called GROUP BY? Is that what I need
>>>to use? Thanks in advance.
>
>
>>Sorry, my mind reading isn't working this morning.
>
>
>
>>It's impossible to tell without knowing the structure of your tables,
>>the code you're using and the output you expect.
>
>
>
>
> Sounds more like a UNION problem, but Jerry is right. We need more
> information to make reasonable comments.
>
> -david-
>
>
> I have a page that displays multiple search results. On each search
> result I want unique information from two or more tables to be
> displayed. All tables have a "client_id" column. I need the main query
> to display results based on the $_GET['keywords'] and a second table to
> display results based on the "client_id" of the main query. I don't
> have any code as of yet to show you. I have done some research on UNION
> and found this on mysql.com:
>
> "Selected columns listed in corresponding positions of each SELECT
> statement should have the same type. (For example, the first column
> selected by the first statement should have the same type as the first
> column selected by the other statements.) The column names used in the
> first SELECT statement are used as the column names for the results
> returned."
>
> Is this going to be a problem since the names and information are going
> to be different on each of my tables.
>

it is a JOIN (implicit) not a UNION

select a.id,a.col2,a.col3,b.col1,b.co2,c.col1,c.col3
from table1 a, table2 b, table3 c
where b.id=a.id and c.id=a.id
and a.id = 123;




--
Michael Austin.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация