我有一个问题
$query = "INSERT INTO `user`
(`fname`,
`lname`,
`email`,
`password`,
`permission`,
`idcustomer`)
VALUES
(
'" . $firstname . "',
'" . $lastname . "',
'" . $email . "',
'" . $password . "',
'admin',
" . $idcustomer . "
);";现在,我只需要执行以下查询的结果是> 0:
select (number_of_users - (select count(*) from user where idcustomer=2)) availableUsers
from customer where idcustomer=2发布于 2012-10-30 05:45:01
只需使用select而不是values(...)
$query = "INSERT INTO `user`
(`fname`,
`lname`,
`email`,
`password`,
`permission`,
`idcustomer`)
select
'" . $firstname . "',
'" . $lastname . "',
'" . $email . "',
'" . $password . "',
'admin',
" . $idcustomer . "
from customer
where idcustomer = 2
and (number_of_users - (select count(*) from user where idcustomer=2)) > 0
);";https://stackoverflow.com/questions/13130000
复制相似问题