473,387 Members | 1,785 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.

accessing different columns with the same name when joining tables

hi,

i have two tables that i am joining using the following sql:

SELECT * FROM clients, programmes WHERE clients.client_id =
programmes.client_id AND programmes.client_id = 12
if both clients table and programmes table contain a column called
date_added, how do i access them both seperately? i have tried the
following:

//after connect code etc.

while ($row = mysql_fetch_array($result)) {
$clients_date_added = $row['clients.date_added'];
}
....but it doesnt seem to work. any help?

cheers

burnsy
Jul 17 '05 #1
2 2022
mr_burns wrote:
i have two tables that i am joining using the following sql:

SELECT * FROM clients, programmes WHERE clients.client_id =
programmes.client_id AND programmes.client_id = 12
if both clients table and programmes table contain a column called
date_added, how do i access them both seperately? i have tried the
following:

//after connect code etc.

while ($row = mysql_fetch_array($result)) {
$clients_date_added = $row['clients.date_added'];
}

...but it doesnt seem to work. any help?


There is going to be a collision, instead, use something like this:

SELECT clients.date_added as c_date_added, programmes.date_added as
p_date_added FROM ...

/marcin
Jul 17 '05 #2
bi******@yahoo.co.uk (mr_burns) emerged reluctantly from the
curtain and staggered drunkenly up to the mic. In a cracked and
slurred voice he muttered:

<snip>
...but it doesnt seem to work. any help?


SELECT c.date_added AS clients_date_added,
p.date_added AS programmes_date_added
FROM clients c, programmes p
WHERE c.client_id = p.client_id
AND p.client_id = 12

while ($row = mysql_fetch_array($result)) {
echo $row['clients_date_added'];
echo $row['programmes_date_added'];
}

You were almost there. However if you wan't to select any more
columns you'll need to explicitly name them.

--
Phil Roberts | Deedle Doot Doo Dee Dee | http://www.flatnet.net/

I could be wrong here, You could be right
Please forgive me I have sinned - Not on your life
But that's how you want me, But I'll never fear thee
Why you and not me? Tell me Holy Man
Jul 17 '05 #3

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

Similar topics

2
by: Darren Smith | last post by:
I am having a great deal of difficulty accessing individual fields generated from a Sql Server 7 view. When I specify the actual field name, I get the error: Microsoft OLE DB Provider for ODBC...
2
by: James | last post by:
Can anyone please shed some light on the following... I have a framework that uses dynamically created tables, named using an incremental "attribute set ID", as follows: attrdata_1 attrdata_2...
17
by: Wilfried | last post by:
Hi, I have 5 tables: main data1
1
by: Moojjoo | last post by:
Good Monday Morning: I am at a dead stop and I am hoping some other developers out there can help me out. I have built a dataset that first contains a table populated from SQL Server then I am...
2
by: sal | last post by:
Greets, all I'm trying to create different multiple mailing type labels on a page reading from an untyped dataset anyone have any ideas on how I can get this done without crystal reports a plan...
19
by: cj | last post by:
I'm getting terrible response times trying to pull data from VFP tables using .net--like 2 minutes! Can someone help? f:\arcust01 currently contains 187,728 records and is indexed on CUSTNO...
2
by: tmcdon05 | last post by:
With VB 2005 - I have a form that has comboboxes for selecting data from tables. User can select a customer name for instance and that is all that is in the combobox and on the form. I Want to take...
4
by: dsdevonsomer | last post by:
Hello, I have one simple query joining two tables with left outer join on 3 fields and using MIN on two fields. These two tables have lot of data about 3 mil in total. I am trying to migrate db...
6
by: Bhawna | last post by:
I am into c++ code maintenance for last 3-4 years but recently I am put into design phase of a new project. Being a small comapany I dont have enough guidance from seniors. Currently I am into a...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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.