Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 选择查询多个表sql server_Php_Mysql_Sql_Sql Server_Magento - Fatal编程技术网

Php 选择查询多个表sql server

Php 选择查询多个表sql server,php,mysql,sql,sql-server,magento,Php,Mysql,Sql,Sql Server,Magento,我是sql server新手。我试图比较两个表(items,catalog),分别是唯一代码(itemsID)和3个catalogsid(catalogID1,catalogID2,catalogID3)。比较之后,我想查看itemDescription(使用我设置的条件/比较)。 我在下面编写了查询,但无法使用3个条件(items.itemsID=catalog.catalogID1和items.itemsID=catalog.catalogID2和items.itemsID=catalog.

我是sql server新手。我试图比较两个表(items,catalog),分别是唯一代码(itemsID)和3个catalogsid(catalogID1,catalogID2,catalogID3)。比较之后,我想查看itemDescription(使用我设置的条件/比较)。 我在下面编写了查询,但无法使用3个条件(items.itemsID=catalog.catalogID1和items.itemsID=catalog.catalogID2和items.itemsID=catalog.catalogID3)执行查询,但如果我自己执行每个条件(例如,items.itemsID=catalog.catalogID1),它确实会执行。 如何在所有3种条件下执行它?任何建议都将不胜感激

select items.itemsDescription
from items, catalog
where items.itemsID = catalog.catalogID1 and items.itemsID = catalog.catalogID2 and items.itemsID = catalog.catalogID3

你的逻辑不正确。您的意思是,
items.itemsID
必须同时是三个不同的值。您需要的是
条件:

WHERE items.itemsID = catalog.catalogID1
   OR items.itemsID = catalog.catalogID2
   OR items.itemsID = catalog.catalogID2
或者更简洁地说:

WHERE items.itemsID IN (catalog.catalogID1, catalog.catalogID2, catalog.catalogID3) 

你能提供一些数据样本吗?我想你需要加入3个项目,但不是保证。使用或代替,我理解,但结果,显示项目。IT描述,将考虑所有3个条件?所以你想要的记录,所有三个目录值是相同的值?不,所有三个目录都是不同的。然后你想要的<代码>或< /代码>版本i以上。谢谢,我去查一下。