-3
SELECT
*
FROM dvcam

LEFT JOIN format AS format1 ON
dvcam.ID_Format=format.ID_Format,

originaltape
LEFT JOIN format AS format2 ON
originaltape.RO_Format=format.ID_Format

谁能帮我这个?

Format 包含 ID_Format 和 Format 保存名称的位置(dvd、vhs 等)

我需要从 dvcam 表和 originaltape 中显示格式(名称)

4

5 回答 5

0

快速猜测:

SELECT
*
FROM dvcam
LEFT JOIN format AS format1 ON
dvcam.ID_Format=format1.ID_Format,

originaltape
LEFT JOIN format AS format2 ON
originaltape.RO_Format=format2.ID_Format
于 2013-06-19T17:48:14.063 回答
0

您需要在第一次加入之后删除并修复子句,中的别名:on

SELECT *
FROM dvcam left join
     format AS format1
     ON dvcam.ID_Format=format1.ID_Format left join
     originaltape left join
     format AS format2
     ON originaltape.RO_Format=format2.ID_Format
于 2013-06-19T17:49:01.177 回答
0

您需要解释更多以及您使用的是哪个数据库(Oracle、SQL Server、MYSql...等)

编辑: 您需要定义 dvcam 和 originaltape 之间的关系,如果 dvcam 与 originaltape 的关系不是 1-1,则您所拥有的连接将不起作用。另一方面,如果它是 1-1 那么你可以做这样的事情

Select *
from
  (SELECT *
    FROM dvcam inner join 
      format as f1 
     /*assuming every record has a format field */
     on dvcam.id_format =f1.id_format) dv inner join
  (SELECT *
    FROM originaltape inner join 
      format as f2 
     /*assuming every record has a format field */
     on originaltape.id_format =f2.id_format) ot 
  on dv.?? = ot.??

HTH 贾法尔

于 2013-06-19T17:51:37.317 回答
0

你可以试试这个,它应该适用于任何数据库:

SELECT
*
FROM dvcam
LEFT JOIN format AS format1 ON
dvcam.ID_Format=format1.ID_Format
LEFT JOIN originaltape ON
originaltape.RO_Format=format1.ID_Format
于 2013-06-19T17:52:33.780 回答
-3

这是我做的..现在可以了..

SELECT dvcam.*, format.Format AS Format, Format2.Format AS Format2

FROM
dvcam
LEFT JOIN format ON
dvcam.ID_Format=format.ID_Format,

originaltape
LEFT JOIN format AS format2 ON
originaltape.RO_Format=format2.ID_Format

感谢您的所有帮助和时间..

于 2013-06-19T18:26:52.967 回答