c# - Trying to use Join to get data from two table into one query search using Join -
i issuing sql query in visual studio application search database. having trouble joining 2 tables 1 query search. looking combine first , last name of employee , match phone number. in 1 table have abbreviated name, , on other table have full name.
code
cmdtxt.append("select partner.staffid, staff.forename,staff.surname tblpartner left join tblstaff on staff.staffid = partner.staffid order staff.forename , staff.surname ");
i have field shows forename , surename, , phone number in 1 query search
you using "partner" , "staff" table aliases, aren't assigning aliases table names. if want use instead of full table names, need:
select partner.staffid, staff.forename,staff.surname, partner.phone tblpartner partner left join tblstaff staff on staff.staffid = partner.staffid order staff.forename , staff.surname
as general advice, query working outside of string literal; enter sql server management studio or similar. had done that, should have showed problem was. when have query set how want, can copy command text in visual studio application.
Comments
Post a Comment