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.

example
enter image description here

enter image description here

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

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -