I need to concatenate a string based on values from two different database, and I think the way I'm going about it is the long way, and I'm hoping someone can simplify this for me (if it can be, I don't know). It's more to do with the SQL query than anything.
I have two different variables representing 2 different id's from two separate tables. I have $artistID which is in artists_table, and $bootlegID which is in master_list. I need to get the artist associated with $artistID and the date associated wtih $bootlegID, then build a string with those 2 results. This is what I have so far (as you'll tell, this is working with phpBB, but that has nothing to do with this):
$subject = 'Review for ';
// first db query
$query = "SELECT artist FROM artists_table WHERE artistID = '$artistID'";
if (!($result = $db->sql_query($query)))
{
message_die(GENERAL_ERROR, 'Error retrieving information', '', __LINE__, __FILE__, $query);
}
if ($row = $db->sql_fetchrow($result))
{
$subject .= $row['artistID'] . " - ";
}
// second query
$query = "SELECT show_date FROM master_list WHERE bootlegID = '$bootlegID'";
if (!($result = $db->sql_query($query)))
{
message_die(GENERAL_ERROR, 'Error retrieving information', '', __LINE__, __FILE__, $query);
}
if ($row = $db->sql_fetchrow($result))
{
$subject .= $row['show_date'];
}
Is there a way to make that one single SQL statement instead of having two different queries? The resulting string would look like "Review for Dream Theater - 3/9/1996". Thanks for any and all help. I'll keep trying on my end, but I've been coding for hours and my brain is slowly turning to mush.
James