Hi,
I have a db with for music collection with 2 tables. One for title information and another table with just tracks. I can get a query to return a title and all the associated tracks but the title is displayed on every line too. Is it possible to display the title once and the associated tracks?
query help
Moderator: General Moderators
It depends on how you script it... And example:
Code: Select all
$result = mysql_query("select a,b from tunes where id = '1'");
$title = '';
while ($row = mysql_fetch_array($result)) {
// check if $title is set, if not, set it and display it.
// else, do nothing.
if (empty($title)) {
$title = $row[0];
echo $row[0];
}
// display the track...
echo $row[1];
}Re: query help
Thats a SQL problem... do an outter query to pull back ONE record for the title and its associated tracks(MANY tracks, ONE record title) = OUTTER QUERY.
ie:
select
blah,
blah2
from
oneTable_t a,
2ndTable_t b
where
a.id(+) = b.id
ie:
select
blah,
blah2
from
oneTable_t a,
2ndTable_t b
where
a.id(+) = b.id
CrazyJimmy wrote:Hi,
I have a db with for music collection with 2 tables. One for title information and another table with just tracks. I can get a query to return a title and all the associated tracks but the title is displayed on every line too. Is it possible to display the title once and the associated tracks?