我有以下 SQL 语句:
select distinct
u.id,
v1.code,
v2.code,
a1.phone,
a1.phone1,
SUM(o1.totalprice) as SALES
SUM(ot4.numbers) as NUMBERS
from
users u,
orders o2
inner join values v1 on v1.pk = u.gender
inner join values v2 on v2.pk = u.egistration
inner join addresses a1 on a1.owner = u.pk
inner join orders o1 on o1.userpk = u.pk
inner join orderthings ot4 on ot4.orderpk = o2.pk
where
u.cccustomer = 1
and
v2.code = 'REGISTERED'
group by
u.id,
v1.code,
v2.code,
a1.phone,
a1.phone1
order by
id;
基本上订单上的连接不起作用,但我需要在与用户 u 无关的两个表上获取附加关系。我怎样才能做到这一点?