about database updation in C#
-
:( If I have 2 or more tables in database ,I want to know how we can establish connection between them and if we have same field common in 2 tables ,how we can update all by updating one table i.e. particular fields that r common.
-
:( If I have 2 or more tables in database ,I want to know how we can establish connection between them and if we have same field common in 2 tables ,how we can update all by updating one table i.e. particular fields that r common.
-
:( If I have 2 or more tables in database ,I want to know how we can establish connection between them and if we have same field common in 2 tables ,how we can update all by updating one table i.e. particular fields that r common.
UPDATE t1, t2 SET t2.datafield='Table2 data', t1.datafield='Table1 Data' WHERE t1.userID=9 AND t2.userID=9
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
-
i am not understanding your question but whatever i got i am telling you.. for making connection you can use join query on table.. If You Get your answer then please Rating me... Thanks.. "Are You Ready" DX-ARMY
AFAIK, JOIN only works for select queries, not for updates - I could be wrong, but I've never seen an UPDATE with a JOIN in!
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
-
AFAIK, JOIN only works for select queries, not for updates - I could be wrong, but I've never seen an UPDATE with a JOIN in!
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
yes you may be right but we can also match the comman field of the table in query..like for example update tablename set ('"+name+"',.....) where table1.id=table2.id and table1.customer_name=table2.customer_name If You Get your answer then please Rating me... Thanks.. "Are You Ready" DX-ARMY
-
:( If I have 2 or more tables in database ,I want to know how we can establish connection between them and if we have same field common in 2 tables ,how we can update all by updating one table i.e. particular fields that r common.
you can also use following method update tablename set ('"+name+"',.....) where table1.id=table2.id and table1.customer_name=table2.customer_name If You Get your answer then please Rating me... Thanks.. "Are You Ready" DX-ARMY
-
yes you may be right but we can also match the comman field of the table in query..like for example update tablename set ('"+name+"',.....) where table1.id=table2.id and table1.customer_name=table2.customer_name If You Get your answer then please Rating me... Thanks.. "Are You Ready" DX-ARMY
Indeed - but as the OP question was about updating...
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
-
Indeed - but as the OP question was about updating...
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
-
AFAIK, JOIN only works for select queries, not for updates - I could be wrong, but I've never seen an UPDATE with a JOIN in!
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
I know at least Microsoft Access and MySQL support joins in UPDATE queries. For your information, go to MySQL's reference page (http://dev.mysql.com/doc/refman/5.0/en/update.html[^]) and search for the word "join" to locate the relating paragraph. I have successfully used UPDATE with join many times. However, not all database systems support this. For example, I have found no support in the small database system "sqlite."
-
:( If I have 2 or more tables in database ,I want to know how we can establish connection between them and if we have same field common in 2 tables ,how we can update all by updating one table i.e. particular fields that r common.
If the columns in common between the tables have unique values, you can define them as foreign keys with the ON UPDATE CASCADE constraint (assuming the database supports foreign keys - I know SQLite only recently added support for them). When you update the column in the table being referenced, it will automatically update the column in the other table. I'm not certain if it works the other way around, but I think it does. Dybs
The shout of progress is not "Eureka!" it's "Strange... that's not what i expected". - peterchen