suchen

Heim  >  Fragen und Antworten  >  Hauptteil

java - 这一条sql哪里错了呀?

SELECT a.*,b.custom_name FROM zqwl_receipt a , zqwl_custom b LEFT JOIN b WHERE a.id= b.id

PHPzPHPz2890 Tage vor192

Antworte allen(6)Ich werde antworten

  • 怪我咯

    怪我咯2017-04-17 18:00:22

    left join的用法一般是先查询主表再join其他表的,比如

    select a.*, b.custom_name from zqwl_receipt a
    left join zqwl_custom b on a.id = b.id

    如果你希望a、b两个表结合查询的结果再做关联查找的话,或许可以用子查询的方式

    select * from (
      select a.*, b.custom_name from zqwl_receipt a, zqwl_custom b where a.id = b.id
    ) t
    left join zqwl_custom t2 on t2.id = t.id

    但是如果写出这样的语句来,最好要要思考a, b两个表的设计问题,
    或者这完全就是没有必要的

    Antwort
    0
  • 天蓬老师

    天蓬老师2017-04-17 18:00:22

    SELECT zqwl_receipt.*,zqwl_custom.custom_name from xxx LEFT JOIN xxx

    Antwort
    0
  • 天蓬老师

    天蓬老师2017-04-17 18:00:22

    from a left join b on a.id=b.id

    Antwort
    0
  • 巴扎黑

    巴扎黑2017-04-17 18:00:22

    你的FROM 去哪里了

    Antwort
    0
  • 黄舟

    黄舟2017-04-17 18:00:22

    没有 from 表
    没有 on 来筛选这两个表的关系。

    SELECT zqwl_receipt.*,zqwl_custom.custom_name from zqwl_receipt LEFT JOIN zqwl_custom on zqwl_custom.字段= zqwl_receipt.字段 WHERE zqwl_receipt.id= zqwl_custom.id

    Antwort
    0
  • PHP中文网

    PHP中文网2017-04-17 18:00:22

    基本语法错误

    Antwort
    0
  • StornierenAntwort