Re: insert using subquery
From: Luuk <luuk_at_invalid.lan>
Date: Sat, 13 Aug 2016 13:41:14 +0200
Message-ID: <57af0752$0$794$e4fe514c_at_news.xs4all.nl>
>> 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: [Quoted] [Quoted]
>> 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)
>>
Date: Sat, 13 Aug 2016 13:41:14 +0200
Message-ID: <57af0752$0$794$e4fe514c_at_news.xs4all.nl>
On 13-08-16 13:38, Luuk wrote:
> 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: [Quoted] [Quoted]
>> 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%') > >
Because the keyword VAULES is not used in the third form that is shown here: http://dev.mysql.com/doc/refman/5.7/en/insert.html Received on Sat Aug 13 2016 - 13:41:14 CEST