Interlacing two separate mysql queries

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm trying to interlace the results from a left-join
query with a regular select result. I have two tables:
Aplications and States (state as in: the states of
Florida and California). Each aplication in the
Aplications table contains a state_id, which matches
an id of a state in the States table. In the States
table each state has a description that is it's full
name (e.g. Virginia). 
So the tables look something like this:
##Table Aplications##
Name        Version  Category     State_Id
Windows       2000     OS             2
FreeBSD       5.0      OS             7

##Table States##
id       Descr
 2     Washington
 7     California

Let's say my query and results are set up like:
$sql = "select * from aplications";
$result = mysql_query($sql, $link);
$row = @ mysql_fetch_array($result);

I then feed the results into an html table that
displays the software, using $row["Name"],
$row["Version"] etc.
BUT my problem is that I need a second sql statement
that looksup and returns the state description, so
that it's included in the table.
So the html row for FreeBSD will look like:
Name     Version   Category      State
FreeBSD    5.0        OS      California

I realize I need a left join sql statement, but what I
don't understand is how to make a query for each piece
of software and have the results displayed in a column
of the html table.
Btw I need a seperate state table because the states
are used by other aplications apart from my own.

I Hope I've been able to explain it correctly.

Thanks, 

J


__________________________________________________
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
http://platinum.yahoo.com

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux