NYCPHP Meetup

NYPHP.org

[nycphp-talk] Grabbing info Twice from the Same Table

Randal Rust rrust at r2communications.com
Thu Feb 24 09:24:27 EST 2005


harvey wrote:

> SELECT shows.name, shows.id, month.month_name AS openmonth
> FROM shows, months
> WHERE shows.openmonth_fid = months.month_id

for clarity's sake, it sounds like your tables are like so...

SHOWS
------------

showName
showID
openMonth_fid
closeMonth_fid

MONTHS
-------------

monthID
monthName

 > How would I go about doing something like the above?

see if the following works. if it doesn't try 'left join' in place of 
inner join.

QUERY
--------------

select s.showName, s.showID, m.monthName as openMonth, m.monthName as 
closeMonth from shows s innner join months m on 
s.openMonth_fid=m.monthID and s.closedMonth_fid=m.monthID

-- 
Randal Rust

R.Squared Communications
http://www.r2communications.com
Digital Design for Bricks-and-Mortar Businesses




More information about the talk mailing list