NYCPHP Meetup

NYPHP.org

[nycphp-talk] Re: newbie question/confusion

Freeman, Joshua j at nybg.org
Tue Feb 22 23:48:35 EST 2005


T H A N K  Y O U  ! !

I used the second syntax first... I'll test the first syntax tomorrow!

Now I just have to figure out how to write my insert statement for when people want to add gardens!

;-)

J.

Joshua S. Freeman
Director, Information Technology, NYBG
v: 718 817 8937 m: 347 392 2560
jfreeman at nybg dot org



-----Original Message-----
From: talk-bounces at lists.nyphp.org on behalf of Faber Fedor
Sent: Tue 2/22/2005 11:27 PM
To: NYPHP Talk
Subject: [nycphp-talk] Re: newbie question/confusion
 
On 22/02/05 23:10 -0500, Freeman, Joshua wrote:
> I am at a complete and total loss as to how to edit my code at this
> point so that, before displaying anything, i can grab either
> 'state_abbr' or 'state_name' from the states table, properly
> associated with the 'state_id' and display the actual state
> abbreviation or state name in my web page.

Are you asking "how do I do a JOIN on the tables"?

SELECT botgard_name, botgard_address,
yadayadayada, state_abbr
FROM gardens LEFT JOIN states 
ON gardens.state_id = states.state_id

(I think that's the syntx) or, to be safer, you might want to do

SELECT botgard_name, botgard_address,
yadayadayada, state_abbr
FROM gardens, states
WHERE gardens.state_id = states.state_id

(I know that syntax will work). There are subtle differences between the
two, but either should work in your circumstance.

You want to RTFM at http://dev.mysql.com/doc/mysql/en/join.html which
isn't too helpful, IMO, or try
http://www.devshed.com/c/a/MySQL/MySQL-Table-Joins/

-- 
 
Regards,
 
Faber                     

Linux New Jersey: Open Source Solutions for New Jersey
http://www.linuxnj.com



_______________________________________________
New York PHP Talk Mailing List
AMP Technology
Supporting Apache, MySQL and PHP
http://lists.nyphp.org/mailman/listinfo/talk
http://www.nyphp.org




-------------- next part --------------
A non-text attachment was scrubbed...
Name: winmail.dat
Type: application/ms-tnef
Size: 3499 bytes
Desc: not available
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20050222/0c42fe5b/attachment.bin>


More information about the talk mailing list