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.
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.
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.
A blank text file should appear in the centre panel of MySQL Workbench.
- Copy the block of code below
SELECT * FROM user;
Paste the copied code into the blank text 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.
Click on the execute icon
View the table in the centre panel.
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.
Locate the ‘Navigator’ panel to the left for a list of your current schemas.
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.
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.
Click on the arrow next to the ‘Tables’ item to display the list of tables as we did in Step 2.
Right click on the name of the table you would like to display.
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.