Using SELECT to INSERT records in SQL
In MS SQL, very often I want to insert records into a table based on the record set of another query I have.
I always end up looking up this over and over, so here it is for your reference and mine.
INSERT table_desitination
(td_field1, td_field2) SELECT ts_field1, ts_field2 FROM table_source
Select and Insert or Update in MySQL
I forget this every time.
1. Select and Insert
INSERT INTO table1 ( table1.column1, table1.column2 ) SELECT table2.code, table2.name FROM table2;
2. Select and Update (actually, JOIN UPDATE)
UPDATE
table1, table2
SET
table1.column1 = table2.column1
WHERE
table1.column_key = table2.column_key;
Reference:
How to insert source code pretty in Tumblr.
Use google-code-prettify like this.
Yes, looks lik just this post.
<link rel="stylesheet" href="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css" type="text/css" media="screen" />
<script type="text/javascript" src="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js"></script>
<style type="text/css">
pre {
padding: 5px 10px;
word-wrap: break-word;
margin-bottom: 14px;
font-family: 'Lucida Console', Monaco, monospace;
}
pre.prettyprint {
padding: 5px 10px;
word-wrap: break-word;
margin-bottom: 14px;
border:1px solid #dedede;
font-family: 'Lucida Console', Monaco, monospace;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
}
.
.
.
</style>
<body onload="prettyPrint()">
.
.
.
</body>
Reference: