search

Home  >  Q&A  >  body text

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

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

PHPzPHPz2890 days ago194

reply all(6)I'll reply

  • 怪我咯

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

    The usage of

    left join is generally to query the main table first and then join other tables, such as

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

    If you want to combine the query results of two tables a and b and then perform a related search, you may be able to use a subquery

    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

    But if you write such a statement, you’d better think about the design issues of tables a and b,
    or this is completely unnecessary

    reply
    0
  • 天蓬老师

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

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

    reply
    0
  • 天蓬老师

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

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

    reply
    0
  • 巴扎黑

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

    Where did your FROM go

    reply
    0
  • 黄舟

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

    There is no from table
    There is no on to filter the relationship between these two tables.

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

    reply
    0
  • PHP中文网

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

    Basic syntax errors

    reply
    0
  • Cancelreply