You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'and wp.wsymbol = wm.wsymbol order by wp.wsymbol' at line 2 Q=select wp.wrecnum,wp.wallocated,wp.wsymbol,wp.wshares,wp.wtype,wp.wprice,wp.wdatetime,wm.wname,wm.wcurrent,wm.wbid,wm.wask from tsbpositions as wp,tsbmarket as wm
where wtype = 'LONG' and wwpid= and wp.wsymbol = wm.wsymbol order by wp.wsymbol