473,387 Members | 1,520 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Aligning multiple query results

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.

Jan 9 '06 #1
1 1513
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.
Jan 9 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Rick Caborn | last post by:
Does anyone know of a way to execute sql code from a dynamically built text field? Before beginning, let me state that I know this db architecture is built solely for frustration and I hope to...
4
by: DG | last post by:
Hi, Can anyone advise how to execute multiple statements in a single query batch. For example- update customers set customer_name = 'Smith' where customer_name = 'Smyth'; select * from...
3
by: Gord | last post by:
I would like to create a summary report from the results of 11 queries (based on 2 tables). All the queries have the same format and return 3 numbers (Count, Current Year Bal, Last Year Bal.)...
2
by: Scott Cannon | last post by:
I am trying to query 3 tables all related by Clinet_ID. The Clients table, Monthly_Expenses table and Monthly_Income table. Each client can have 0>M instances of expenses, past due expenses, and...
5
by: Beacher | last post by:
I've noticed that you can only have a sub datasheet pointing to one table... is there anyway to change this? for example I have Customer | ---------- Customer/Product | -----------...
28
by: kiqyou_vf | last post by:
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...
1
by: Barb.Richards | last post by:
I have created an append query that pulls information from one database, and will append the selected information into a new table. The fields are setup like 'number' 'category' 'code' 'shares' and...
1
by: tjm0713 | last post by:
Not sure this can be done but here is my current situation. I have a table containing millions of records. Each record has 28 fields. One of the fields I am trying to return the single record for...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.