SELECT a.*,b.custom_name FROM zqwl_receipt a , zqwl_custom b LEFT JOIN b WHERE a.id= b.id
怪我咯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
黄舟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