Re: insert using subquery
Date: Sat, 13 Aug 2016 13:38:28 +0200
Message-ID: <57af06ac$0$794$e4fe514c_at_news.xs4all.nl>
On 13-08-16 13:29, bill wrote:
> On 8/13/2016 7:03 AM, bill wrote:
>> I have a query that works:
>>
>> SELECT `transNum` FROM `transactions`
>> where
>> `description` LIKE 'Quality Reporting%'
>>
>> now I want to make it a subquery in order to insert transNum into
>> another table
>>
>> insert into pendingInsBillings (transNum) Values (??)
>> here (SELECT `transNum` FROM `transactions`
>> where
>> `description` LIKE 'Quality Reporting%')
>>
>> I just can't figure out what to replace the ?? with in the main
>> query in order to get the value of transNum from the subquery.
>>
>> bill
>
> I tried:
> INSERT INTO `pendingInsBillings`(`transNum`)
> VALUES ((SELECT `transNum` FROM `transactions`
> where
> `description` LIKE 'Quality Reporting%'))
>
> but get the error 1242 Subquery returns more than 1 row
> (which is true)
>
Try:
INSERT INTO `pendingInsBillings`(`transNum`)
(SELECT `transNum` FROM `transactions`
where
`description` LIKE 'Quality Reporting%')
Received on Sat Aug 13 2016 - 13:38:28 CEST