insert a select inside a select?

homer.favenir

Verified User
Joined
Feb 19, 2008
Messages
12
Location
manila, philippines
hi to all
could any one please help me with this.
it has an error: "Subquery returns more than 1 row"
Code:
SELECT
tbl_transactions.artid,
sec_to_time(sum(time_to_sec(timediff(dtecompleted,dtestarted)))) as 'Total Time Spent',
tbl_received.dtedue as 'Due Date',
(SELECT tbl_transactions.dtestarted FROM tbl_transactions where tbl_transactions.transcode = 'SH') as 'ship date'

from
tbl_transactions
inner join tbl_user on (tbl_transactions.startedby = tbl_user.userid)
inner join tbl_received on (tbl_transactions.artid = tbl_received.artid)

group by
artid

order by
artid
please check my code

thanks
 
I'm not sure, if it works correctly, but
Code:
SELECT
tbl_transactions.artid,
sec_to_time(sum(time_to_sec(timediff(dtecompleted,dtestarted)))) as 'Total Time Spent',
tbl_received.dtedue as 'Due Date',
(SELECT tbl_transactions.dtestarted FROM tbl_transactions where tbl_transactions.transcode = 'SH' [U]LIMIT 1[/U]) as 'ship date'

from
tbl_transactions
inner join tbl_user on (tbl_transactions.startedby = tbl_user.userid)
inner join tbl_received on (tbl_transactions.artid = tbl_received.artid)

group by
artid

order by
artid
hi to all
could any one please help me with this.
it has an error: "Subquery returns more than 1 row"
Code:
SELECT
tbl_transactions.artid,
sec_to_time(sum(time_to_sec(timediff(dtecompleted,dtestarted)))) as 'Total Time Spent',
tbl_received.dtedue as 'Due Date',
(SELECT tbl_transactions.dtestarted FROM tbl_transactions where tbl_transactions.transcode = 'SH') as 'ship date'

from
tbl_transactions
inner join tbl_user on (tbl_transactions.startedby = tbl_user.userid)
inner join tbl_received on (tbl_transactions.artid = tbl_received.artid)

group by
artid

order by
artid
please check my code

thanks
 
You'll have to specify more options to narrow down the results of the sub-query. The sub-query is returning more than one result when it shouldn't as then the information can be grouped.

Code:
SELECT tbl_transactions.dtestarted FROM tbl_transactions where tbl_transactions.transcode = 'SH'
 
Back
Top