Running SQL statements with MySQLGUI

Running a query or other SQL statement is really quite simple with MySQLGUI. Simply type the query into the box as shown in Figure 8-40, using a simple query on the mysql database such as SELECT * FROM user.

5 MySQL client

^LQ! x|

Manage Commands Hierarchy He^

Query results :

■ Screen P| File _| Count

J #**SQL

| Connected | mysql ^^J

Choose Execute 1 Save „, L , . Clear Options tables query | queiy | 1

Help E\it

SELECT * FROM usex;|

("■j^Fuuiul 9 tables ") Info

Figure 8-40: Executing SQL statements with MySQLGUI is easy, as shown by this simple query.

You can choose of what you'd like to do with the results from the statement. Figures 8-36 through 8-39 show three buttons across the top of the main MySQLGUI screen — Screen, File, and Count — that also represent those choices:

♦ Screen: By default, the Screen option is selected, which prints the results of any statement on-screen only. The results of the SELECT * FROM user query open a new dialog box, as shown in Figure 8-41.

Figure 8-41: When you print the results of a statement to the screen, a new dialog box opens automatically.

The Results box gives you the option to save your results to a file.

♦ File: If you want to save the results to a file directly, click the File button. A dialog box similar to the one shown in Figure 8-42 appears, prompting you for the location to which you want to send the results. In response to the prompt for a filename, you can choose to create a new file or append the results to an existing file.

Sort Alpha

-

Filter r Files _i | Pattern *

_i

MySQL.help

README

my.cnf

my. cnf. win

mysqlgui.exe*

readme.version

1

readme.version

.1.1

readme.version

.3

readme.version

.4

readme.version

6

readme.version

.7

zJ

readme.version

.7.2

i

1

Please enter or select file

Append

Append

Figure 8-42: To save the results to a file, you must select the location and filename for MySQLGUI to send the results to.

♦ Count: Select this button if you want to see a count of the results instead of printing the output to the screen or to a file. The count appears in the Information section at the bottom of the MySQLGUI screen. For example, the SELECT * FROM user query returns 9 rows, as shown in Figure 8-43. The count results appear in the Information section at the bottom of the figure.

You can also use MySQLGUI to limit the number of rows returned by a query. Click Commands O Query O With Limit. A slider-bar appears at the bottom of the main MySQLGUI program screen, as shown in Figure 8-44. Simply slide the bar to the left or right, by left-clicking with the mouse and dragging the bar.

5 MySQL client

Manage Commands Hierarchy Helfj

Query results :

_J Screen P| File ■ Count

J rf^SQl

| Connected | mysql ^^J

Choose Execute 1 Save „, L , . Clear Options tables query | query | 1

Help Exit

^SELECT * FROM user;

(SELECT * FROM user; |

(^j^Number o f rows = 9 ) Info

Figure 8-43: Select the Count option displays the number of rows returned by the statement in the Information section of the MySQLGUI screen.

|H MySQL client

JSl*]!

Manage Commands Hierarchy Helg

Query results : | Screen IBI File Q Count

J ^SQL

| Connected j mysql

Choose Execute 1 Save tables

Clear Options

Help | Exit

  • ELECT * FROM user
  • ELECT * FROM user

SELECT * FROM usei

0 50 1

11111I I11111I I11111 jl 11111 jl 11111 jl 1111111111111111111| 111111| 11111 l|l 11111 l|l 11111 l|l 11111 |l 11111 |l 111111111111111111 ^

)0 150 200 250 300 350 400 450 500 550 000 650 700 750 800 850 000 950

100

Figure 8-44: You can limit the rows returned by a query by selecting the With Limit option.

0 0

Post a comment

  • Receive news updates via email from this site