Heim > Backend-Entwicklung > PHP-Tutorial > 一次将两个属性拿出,该如何处理

一次将两个属性拿出,该如何处理

WBOY
Freigeben: 2016-06-13 13:46:41
Original
971 Leute haben es durchsucht

一次将两个属性拿出
include("conn.php");
$rs=mysql_query("
SELECT products_des_options_values.options_values
FROM products_des_options_values
JOIN products_des_attributes ON products_des_options_values.id = products_des_attributes.products_des_options_values_id
JOIN products ON products.id = products_des_attributes.products_id 
join products_des_options on products_des_options.id = products_des_attributes.products_des_options_id
WHERE product_type='41' and STATUS !='D' and products_des_options.id =31 and ppcode like '%ACK2804N%'
order by products_des_options_values.options_values

union

SELECT products_des_options_values.options_values
FROM products_des_options_values
JOIN products_des_attributes ON products_des_options_values.id = products_des_attributes.products_des_options_values_id
JOIN products ON products.id = products_des_attributes.products_id 
join products_des_options on products_des_options.id = products_des_attributes.products_des_options_id
WHERE product_type='41' and STATUS !='D' and products_des_options.id =35 and ppcode like '%ACK2804N%'
order by products_des_options_values.options_values ");

while($row=mysql_fetch_array($rs) and $row2=mysql_fetch_array($rs2))
{  
echo $V="$row[options_values]
";
echo $A="$row2[options_values]
";
echo $V * $A."

";
}
 

?>

我在phpmydamin下运行,老是报错:#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT options_values FROM products_des_options_values JOIN products_des_attribu' at line 2




------解决方案--------------------
鉴于你的表名比较长。建议查询时为每个表起个别名。然后查询列和条件加上别名。

合并的话。用in 或者or 或者union all 都可以。

Verwandte Etiketten:
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage