Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
inri
Starting Member
3 Posts |
Posted - 2011-08-12 : 12:09:39
|
| hi...i need a help to solve this problem..i have a table MS_EducatedData consist by column:applicant_id, degree_id, univ_id, univ_otherwith value each row :first row:"lisa_ananta@yahoo.com","1","999","arendiktus university"second row:"inri.martha@yahoo.co.id","2","999"," eselina university"third row:"inri.martha@yahoo.co.id","1","1","(empty) "table Degree consist by column:degree_id,degree_namewith value each row :first row: "1","master"second row: "2","bachelor"and table MS_univ consist by colomn:univ_id,univ_namewith value each row :first row: "1","samantha university"second row: "999","other"my destination result is: whenever the applicant_id is inri.martha@yahoo.co.idand already insert twice of education chosen so the result in other table with name is result and consist by column: degree_name, degree_id will be:1 row: "bachelor", "eselina university"2 row: "master", "samantha university"can u help me how i have to write the correct syntax...? |
|
|
Dasman
Yak Posting Veteran
79 Posts |
Posted - 2011-08-12 : 15:47:48
|
| Are u saying you have TWO records of applicant_id of "inri.martha@yahoo.co.id" and for the second record where the univ_other is empty - You would like to UPDATE it with"samantha university?"If so you want to look into the SQL Operator called UPDATE! http://www.w3schools.com/sql/sql_update.aspThe syntax is like this:UPDATE table_nameSET column1=value, column2=value2,...WHERE some_column=some_valueNOTE: BE VERY CAREFUL with the UPDATE, INSERT, and DELETE commands - they CHANGE your database, whereas simple queries just pull data from tables and show results.This is a sample query - PLEASE CHECK before running:Update YOURTABLENAMESET Univ_other = 'samantha university'WHERE applicant_id = 'inri.martha@yahoo.co.id' AND degree_id = 1 AND univ_id = 1.Others please chech this. Best of Luck!Dasman==========================Pain is Weakness Leaving the Body. |
 |
|
|
inri
Starting Member
3 Posts |
Posted - 2011-08-13 : 08:13:57
|
| thanks before .but i dont want to update samantha university in univ_other. so it will be still emptybecause i am already set samantha university in table MS_univ. when the select query what i make is run. the select query detect the univ_id from table MS_univ and insert the univ_id value into MS_EducatedData. my qouestion is HOW I can SELECT DEGREE NAME AND, UNIV NAME FROM MS_EducatedData WHERE APPLICANT ID = "inri.martha@yahoo.co.id" but in this condition the univ name take from univ_id with value not same with id = 9999 where the univ name take from table Ms_univ and if id = 9999 so it select the univ name from univ other. can u help me please...thanksnever give up until find the way... |
 |
|
|
|
|
|
|
|