Difference between revisions of "MySQL"

Jump to navigation Jump to search
56 bytes added ,  11:55, 14 February 2011
(→‎SELECT Rows: Added COUNT)
Line 134: Line 134:


<br>'''UPDATE ... SELECT'''<br>
<br>'''UPDATE ... SELECT'''<br>
The syntax is not <code>UPDATE ... SELECT</code>, but it performs the function you'd expect from such a query, although its a little mis-leading.  In the example below the <code>plat</code> table is updated from the <code>os</code> table.
Here the <code>table</code> table is being updated from the <code>hware</code> table.
<source lang="mysql">UPDATE table SET make=(SELECT make FROM hware WHERE id=5) WHERE tid=2;</source>
 
Alternatively, the example below the <code>plat</code> table is updated from the <code>os</code> table.
<source lang="mysql">UPDATE plat,os SET plat.osid=os.osid WHERE os.os_supplied='Microsoft(R) Windows(R) Server 2003, Standard Edition';</source>
<source lang="mysql">UPDATE plat,os SET plat.osid=os.osid WHERE os.os_supplied='Microsoft(R) Windows(R) Server 2003, Standard Edition';</source>


Navigation menu