简体   繁体   中英

sql concatenation

Can I concatenate queries like below? If no, how should I proceed? I don't want to read rows from $retrieveUnitExist as it waste another step.

$retrieveUnitExist = "SELECT unitid FROM ESTATEUNIT WHERE BLOCK = 1";
$insertAddress = "INSERT INTO ADDRESS (value1, value2) VALUES ('1','".$retrieveUnitExist."')";

mysqli_query($conn, $insertAddress);

Something like this?

$insertAddress = "INSERT INTO ADDRESS (value1, value2)
                  SELECT '1', unitid FROM ESTATEUNIT WHERE BLOCK = 1";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM