473,396 Members | 1,827 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,396 software developers and data experts.

results of same field names but different tables in mySQL query.

LRW
I have a SQL string with a couple of JOINs that works perfectly in
command prompt. I get results for all the fields selected just fine.
But when I put it into a PHP page, I can't make variables(?) out of
fields that have the same field name from different tables.
Here's the SQL statement:

$sql = "SELECT orders.companyid,orders.ordernum,orders.address,tb l_ih_accounts.company,tbl_ih_accounts.address
FROM orderstatus ".
"LEFT JOIN orders ON (orderstatus.ordernum = orders.ordernum) ".
"LEFT JOIN tbl_ih_accounts ON (tbl_ih_accounts.id = ihid) ".
"WHERE submitted <> 'yes' ORDER BY orders.ordernum ASC";

Then in the "WHILE" clause after the database is queried:
$o_address = $row[orders.address];
$ih_address = $row[tbl_ih_accounts.address];

I've tried it without the table names in the $row statements, but then
I'll just get the results for tbl_ih_accounts.address.
I'm thinking there must be some way to uniquely "name" the results of
a particular field up in the SQL statement, and then just use that
unique name in the WHILE. But I have no clue, and can't find anything
about anything like that.

If someone can just point me to a site, or just give me the name of
the concept I can then search mysql.org or wherever and learn about
it.
Thanks!
Liam
Jul 17 '05 #1
1 2927
In article <3a**************************@posting.google.com >,
de**@celticbear.com (LRW) wrote:
I'm thinking there must be some way to uniquely "name" the results of
a particular field up in the SQL statement, and then just use that
unique name in the WHILE. But I have no clue, and can't find anything
about anything like that.


SELECT table1.field AS uniquename1, table2.field AS uniquename2 ...

JP

--
Sorry, <de*****@cauce.org> is een "spam trap".
E-mail adres is <jpk"at"akamail.com>, waarbij "at" = @.
Jul 17 '05 #2

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

Similar topics

0
by: Jim Moseby | last post by:
I stumbled across this while trying to update a table with a timestamp type column. At the time, I didn't know that the timstamp column would update itself when a row was changed. A kind gentleman...
13
by: John young | last post by:
I have been looking for an answer to a problem and have found this group and hope you can assist . I have been re doing a data base I have made for a car club I am with and have been trying to...
15
by: Richard Hollenbeck | last post by:
For example, one college course has only 24 students in it, but the following code says there are zero As, 20 Bs, 16 Cs, 4 Ds, and 8 Fs. When it prints it then says 0 As, 40 Bs, 32 Cs, 8 Ds, and...
4
by: d.p. | last post by:
Hi all, I'm using MS Access 2003. Bare with me on this description....here's the situation: Imagine insurance, and working out premiums for different insured properties. The rates for calculating...
2
by: Lyn | last post by:
Hi, How do you bind the output columns from a UNION query when the fields from the two tables have different names? Consider this query (WHERE clauses omitted)... SELECT SurnameBirth,...
6
by: Brian | last post by:
Hello, Basically, I'm running a query on a form's activation, and I'd like to have the results of the query be placed into other fields on the same form automatically. Does anybody know how...
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: kiqyou_vf | last post by:
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...
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:
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.