Link Search Menu Expand Document

Query to Display Data

For this section we will be displaying a table from the database in MySQL Workbench.

This tutorial works with the table used in Query to Modify Data and also works with any tables on MySQL in general.

A visual representation of a table in MySQL will look like the following figure.

MySQL Workbench visual table

As shown in the figure above, the column names are listed at the top followed by every row of student information inserted into the table.

Follow the steps below to acheive this.

  1. In MySQL Workbench, click the ‘Create a new SQL tab for executing queries’ icon at the top left corner of the window as shown below.

    MySQL Workbench new SQL query tab

    A blank text file should appear in the centre panel of MySQL Workbench.

    MySQL Workbench blank text file

  2. Copy the block of code below
     SELECT *
     FROM user;
    
  3. Paste the copied code into the blank text file.

    MySQL Workbench code pasted to query file

    The * here can be thought of the word ‘all’.

    If you are using a different table you can replace user from the copied code from Step 2.

    MySQL Workbench code pasted to query file different table name

  4. Click on the execute icon

    MySQL Workbench execute tab

  5. View the table in the centre panel.

    MySQL Workbench table is now visible

    Depending on your window size, you may need to hover your mouse over any of the four sides of the panel to readjust its size.


Displaying the entire table can also be done through the MySQL Workbench graphical user interface.

  1. Locate the ‘Navigator’ panel to the left for a list of your current schemas.

    MySQL Workbench navigator panel

    If the ‘Navigator’ panel is not showing your current schemas, click on the ‘Schemas’ tab at the bottom of the panel to display a list of your schemas.

    MySQL Workbench administration and schemas tabs

  2. Click on the arrow next to the schema containing the table you would like to display.

    Another list of items should appear directly underneath your schema, and the arrow next to the schema should be pointing down.

    MySQL Workbench sublist appears under schema

  3. Click on the arrow next to the ‘Tables’ item to display the list of tables as we did in Step 2.

    MySQL Workbench tables list

  4. Right click on the name of the table you would like to display.

    MySQL Workbench right clicking a table

    Click on ‘Select Rows - Limit 1000’. A new tab with SQL code and a visual representation of the table will appear in the centre panel.

    MySQL Workbench visual table shown