java - 这一条sql哪里错了呀?
PHPz
PHPz 2017-04-17 17:58:22
0
6
182

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

PHPz
PHPz

学习是最好的投资!

reply all(6)
刘奇

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

Peter_Zhu

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

Peter_Zhu

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

巴扎黑

Where did your FROM go

黄舟

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

洪涛

Basic syntax errors

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template