从表中选择列名称与另一个表中的数据相等

I am running this SQL Query:

$sql2="SELECT * from callplanmeta ";
$rs2=mysql_query($sql2,$conn) or die(mysql_error());
while($result2=mysql_fetch_array($rs2))
{
    $column_list[] = $result2["callplanname"];
}

$sql="SELECT LEAST(NULLIF(".implode(',',$column_list).",0)) as num FROM callplandata ";
$rs=mysql_query($sql,$conn) or die(mysql_error());
while($result=mysql_fetch_array($rs))
{
    echo $result["description"].' - '.$result["num"].'<br><br>';
}

So in the callplanmeta table are rows with the column names for the callplandata table.

This query is working fine but I need a way to stop it from showing values that are zero from the $result["num"] result. I want it to not show the zero values and just show the next one for every row.

You should try:

$sql="SELECT LEAST(NULLIF(".implode(',',$column_list).",0)) as num FROM callplandata WHERE LEAST(NULLIF(".implode(',',$column_list).",0)) != 0";

instead of:

$sql="SELECT LEAST(NULLIF(".implode(',',$column_list).",0)) as num FROM callplandata ";