Two tables, a user table, a table wallet
I want to write a query, according to user table money order, and the user table money value of the original, according to the associated userid and wallet table do, generate new money value,
Don't write foreach, only query methods, writing a native SQL statements directly, can not achieve,
My code is
"SELECT a.u ser_id, a.n ickname, arjun obile,
(SELECT sum (b.s ela_stock) from tp_sela_stock as b where b.u ser_id=a.u ser_id AND b.s tatus=1) as the ls,
A.f rozen_money, (a.u ser_money + ls) as user_money,
A.r eg_time FROM tp_users as a order by a.u ser_money DESC limit $Page - & gt; FirstRow, $Page - & gt; ListRows ";
I debugged, if user_money value, do not add the ls, can run, and it can display properly the value of the ls
Plus + ls, no hint I ls fields exist,
Big fingers,