If you want to use subqueries, you need to use them as part of a SELECT
, not as part of the scalar values you list in VALUES
. And FoxPro does not allow a SELECT
without a FROM
.
Your simplified query follows (note that you'll want to remove the line breaks or insert semicolons to wrap the string when you send it to VFP):
INSERT INTO CUENTAS (
NUM_CTA,
NUB_CTA,
CAJ_CTA, FEC_CTA, HOR_CTA, OPE_CTA, MES_CTA,
NOM_CTA,
UBI_CTA, PER_CTA, ACU_CTA, USU_CTA, KDI_CTA
)
SELECT
'0000001',
DES_MEZ ,
'01', '2013/07/18', '16:50:33', 0,'002',
(SELECT DES_MES FROM MESEROS WHERE COD_MES = '002'),
'T01', '2',0.00, 01, 0.00
FROM MESAS WHERE COD_MEZ = 'T01'
Note that when writing an INSERT...SELECT
statement, adding proper column names to the SELECT is valid and good practice.