Difference between revisions of "MySQL"

Jump to navigation Jump to search
440 bytes added ,  13:52, 18 January 2011
→‎JOIN: Added furthetr JOIN examples
(→‎Data Types: Added Strings)
(→‎JOIN: Added furthetr JOIN examples)
Line 148: Line 148:


=== JOIN ===
=== JOIN ===
<source lang="mysql">SELECT make, model FROM table JOIN hosts ON table.id=hosts.id WHERE hosts.ip=INET_ATON('10.10.255.253');</source>
<source lang="mysql">
SELECT make, model FROM table JOIN hosts ON table.id=hosts.id WHERE hosts.ip=INET_ATON('10.10.255.253');                 # Join with ON
SELECT make, model FROM table JOIN hosts USING (id) WHERE hosts.ip=INET_ATON('10.10.255.253');                          # Join with USING
SELECT make, model, info FROM table JOIN hosts USING (id) JOIN notes ON (id) WHERE hosts.ip=INET_ATON('10.10.255.253');  # Multiple join
</source>


Different types of join will yield differing results, depending how different rows match up see http://www.wellho.net/mouth/158_MySQL-LEFT-JOIN-and-RIGHT-JOIN-INNER-JOIN-and-OUTER-JOIN.html
Different types of join will yield differing results, depending how different rows match up.  It can be a bit flummoxing to start with, but its actually fairly simple once you've got the basic idea straight in your head, see - http://www.wellho.net/mouth/158_MySQL-LEFT-JOIN-and-RIGHT-JOIN-INNER-JOIN-and-OUTER-JOIN.html


== Migrate Databases ==
== Migrate Databases ==

Navigation menu