×
Create a new article
Write your page title here:
We currently have 3,189 articles on s23. Type your article name above or create one of the articles listed here!



    s23
    3,189Articles

    Mysql: Difference between revisions

    Content added Content deleted
    imported>mutante
    mNo edit summary
     
    imported>mutante
    Line 77: Line 77:
    </pre>
    </pre>


    === Using wildcards ===
    You can use [[wildcard]] like in:

    You can use [[wildcards]] like in:
    <pre>mysql> select * from interwiki;</pre>
    <pre>mysql> select * from interwiki;</pre>

    === Conditions (WHERE-clause) ===


    You can combine with conditions like in:
    You can combine with conditions like in:

    Revision as of 13:16, 9 February 2005

    The world's most popular open source database.


    Examples

    The structure from top to bottom is: server->database->table->field->content

    So get to the place you want in this order:

    Connecting to mysql server from the shell.

    shell> mysql -u root -p
    Enter password:
    Welcome to the MySQL monitor.
    mysql>
    

    Switching into a database.

    mysql> use wikidb;
    Database changed
    mysql>
    

    Showing tables

    mysql> show tables;
    +------------------+
    | Tables_in_wikidb |
    +------------------+
    | archive          |
    | blobs            |
    ...
    | imagelinks       |
    | interwiki        |
    ...
    | watchlist        |
    +------------------+
    23 rows in set (0.00 sec)
    

    Getting field names

    mysql> describe interwiki;
    +-----------+------------+------+-----+---------+-------+
    | Field     | Type       | Null | Key | Default | Extra |
    +-----------+------------+------+-----+---------+-------+
    | iw_prefix | char(32)   |      | PRI |         |       |
    | iw_url    | char(127)  |      |     |         |       |
    | iw_local  | tinyint(1) |      |     | 0       |       |
    +-----------+------------+------+-----+---------+-------+
    3 rows in set (0.00 sec)
    

    Selecting content

    mysql> select iw_prefix from interwiki;
    +-------------------+
    | iw_prefix         |
    +-------------------+
    | AbbeNormal        |
    | AcadWiki          |
    | Acronym           |
    | Advogato          |
    | AIWiki            |
    ...
    | Wiktionary        |
    | YpsiEyeball       |
    | ZWiki             |
    +-------------------+
    107 rows in set (0.00 sec)
    

    Using wildcards

    You can use wildcards like in:

    mysql> select * from interwiki;

    Conditions (WHERE-clause)

    You can combine with conditions like in:

    mysql> select iw_url from interwiki where iw_prefix="UseMod";
    +------------------------------------------+
    | iw_url                                   |
    +------------------------------------------+
    | http://www.usemod.com/cgi-bin/wiki.pl?$1 |
    +------------------------------------------+
    1 row in set (0.00 sec)
    

    .. to be extended ...

    External Links

    Cookies help us deliver our services. By using our services, you agree to our use of cookies.
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.