c# - Trying to select rows from different tables -
select distinct vtw.lastname, vtw.firstname, vtw.dob, vtw.clubnumber, vtw.tournamentname, vtw.bosstournamentid, vtw.tournamentdatetime, vtw.tournamentid, tp.tournamentprizeid, tp.status, tp.place, p.prizeid,p.prizename, tp.bredeemed, tp.couponnumber vwtournamentwinners vtw, tournamentprizes tp, prizes p vtw.fk_tournamentid=tp.fk_tournamentid , vtw.fk_playerid=tp.fk_winnerid , tp.fk_prizeid=p.prizeid , vtw.tournamentdatetime between '8/10/2013' , '8/10/2013' , tp.status='available' union select bossid, status, couponnumber, fk_prizeid, fk_winnerid, prizename, firstname, lastname, dob bountyprizes, prizes, players prizes.prizeid=bountyprizes.fk_prizeid , players.playerid=bountyprizes.fk_winnerid order vtw.tournamentdatetime desc
error message:
msg 205, level 16, state 1, line 1 queries combined using union, intersect or except operator must have equal number of expressions in target lists.
note: both queries work individually. want gridview display blank string columns cannot filled in. chris.
change second select statement to:
select bossid, status, couponnumber, fk_prizeid, fk_winnerid, prizename, firstname, lastname, dob , '', '' , '', '', '', ''
to ensure both queries return same amount of fields
Comments
Post a Comment