Sample commands: Difference between revisions

From www.ReeltoReel.nl Wiki
Jump to navigation Jump to search
No edit summary
 
(One intermediate revision by the same user not shown)
Line 23: Line 23:
</pre>
</pre>
* You can use db_name.tbl_name as an alternative to the tbl_name FROM db_name syntax. In other words, these two statements are equivalent:
* You can use db_name.tbl_name as an alternative to the tbl_name FROM db_name syntax. In other words, these two statements are equivalent:
 
<pre>
<nowiki>SHOW COLUMNS FROM City;
SHOW COLUMNS FROM City;
 
MariaDB [testsietske]> SHOW COLUMNS FROM mytable FROM mydb;
MariaDB [testsietske]> SHOW COLUMNS FROM mytable FROM mydb;
MariaDB [testsietske]> SHOW COLUMNS FROM mydb.mytable;
MariaDB [testsietske]> SHOW COLUMNS FROM mydb.mytable;
</pre>
</nowiki>
* show only first 10 results
* show only first 10 results
<nowiki>MariaDB [testsietske]> select * from City limit 10;
<pre>
</nowiki>  
MariaDB [testsietske]> select * from City limit 10;
</pre>  
* show result 10 to 30
* show result 10 to 30
<nowiki>MariaDB [testsietske]> select * from City limit 20 offset 10;</nowiki>
<pre>
MariaDB [testsietske]> select * from City limit 20 offset 10;</pre>

Latest revision as of 05:58, 3 September 2015

testdatabase 'testsietske';

> mysql -u root

MariaDB [testsietske]> use testsietske;

MariaDB [testsietske]> show tables;

MariaDB [testsietske]> select * from City;

MariaDB [testsietske]> select * from City where Countrycode = "NLD";

MariaDB [testsietske]> select * from City where District = "Noord-Holland";

MariaDB [testsietske]> select * from City where Countrycode = "NLD" and  population > "100000";


MariaDB [testsietske]> show tables;

MariaDB [testsietske]> select * from Country where Continent = "Europe";

----
  • You can use db_name.tbl_name as an alternative to the tbl_name FROM db_name syntax. In other words, these two statements are equivalent:
 SHOW COLUMNS FROM City;
 MariaDB [testsietske]> SHOW COLUMNS FROM mytable FROM mydb;
 MariaDB [testsietske]> SHOW COLUMNS FROM mydb.mytable;
  • show only first 10 results
 MariaDB [testsietske]> select * from City limit 10;
  • show result 10 to 30
 MariaDB [testsietske]> select * from City limit 20 offset 10;