Need a Help!

Need a Help!

am 12.12.2005 20:41:59 von Mohamed Yusuf

------=_Part_24433_20157864.1134416519309
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

I have table and insert data using song_id, that means one artist can have
many song_ids. my question is how can I query distinct artist with his/her
song_id while I will not get duplicate data like duplicate artist?
my code is like this

$content .=3D"



";

that code is fine except it gives me duplicate artist, so I want get rid of=
f
that duplicate. any help

------=_Part_24433_20157864.1134416519309--

Re: Need a Help!

am 12.12.2005 21:44:04 von Trevor Gryffyn

Couple of things you can do:

1. Drop the song ID and only get the artist information "SELECT distinct(Artist) from songtable". It doesn't look like your SELECT statement needs a song, but you include the song ID as $id anyway. Any reason for that or can you drop it so you only get artist?

2. Pre-parse the results of your current query so you only get one artist and/or compile a list of song ID's while you're at it. Instead of doing your ";


$result= $db->sql_query("SELECT distinct(artist), id FROM
".$prefix."_lyrics order by artist asc");
if ($db->sql_numrows($result))
while($row = $db->sql_fetchrow($result))
extract($row);
$content .="";



$content .="
";

that code is fine except it gives me duplicate artist, so I want get rid off
that duplicate. any help


___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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