How To Execute A SQL Query

Table of contents:

How To Execute A SQL Query
How To Execute A SQL Query

Video: How To Execute A SQL Query

Video: How To Execute A SQL Query
Video: Best Way to Write Basic SQL Queries 2024, May
Anonim

An unprofessional programmer most often has to deal with SQL queries when working with Internet resources. Most of them are blogs, forums, site management systems, etc. - uses the MySQL database in the work. For this DBMS, there is a very popular application that allows you to manage both individual tables and entire databases. Creating SQL queries in PhpMyAdmin - this is the name of this application - is possible both in a dialog format and using manual operator input.

How to execute a SQL query
How to execute a SQL query

Necessary

Access to PhpMyAdmin application

Instructions

Step 1

Load the main page of the application into the browser, enter your username and password. In the left column of the first page there is a list of links to the databases available to you - select the one you need.

Step 2

The contents of the left and right columns will change - the list of tables will take the place of the list of databases on the left. If you want to make a query to a specific table, click on the corresponding link, and if the query refers to the entire database, click on the SQL tab in the menu of the right column. After selecting a table, such a tab will also be present on the page and you will also need to go to it.

Step 3

Type your query in the box under the "Execute SQL query (s) against mysql database:" If you did not select a table in the previous step, this field will be empty, otherwise a template will be placed in it, which will only have to be supplemented or corrected. The template may look, for example, like this: SELECT * FROM `help_category` WHERE 1You can immediately click the OK button, and a query will be made to the database - it will return a list of all rows with all fields from the table named help_category.

Step 4

When constructing an SQL query for a selected table, you can use the list of columns available in it - it is placed to the right of the input field. For example, you can transform the template to the following form: SELECT `url` FROM` help_category` WHERE `name` =" Geometric constructions "Pay attention to the quotation marks: the names of fields and tables - url, name and help_category - are not used for quotation marks symbols that are placed around text data (Geometric Structures). After clicking OK, this query will return those table rows that have the value "Geometric structures" in the name field. The list of results will have only one url column, since only it is specified after the SELECT statement.

Step 5

The same request can be generated online. To do this, click the "Search" link and fill in the table under the "Execute" query by sample "text. For the above example, in this table it is enough to type the text “Geometric constructions” in the “Value” column of the name line. To construct more complex queries, click the "Parameters" link located below the table, and an additional set of fields and selection lists will open.

Step 6

Click OK and PhpMyAdmin will construct and send the SQL query to the database.

Recommended: