MySQL SELECT statement and mysqlselect statement

Source: Internet
Author: User

MySQL SELECT statement and mysqlselect statement

SELECT statement:

The products table is as follows:



A selects a column FROM a table: mysql> SELECT prod_name FROM products;



B. Retrieve multiple columns FROM the table: mysql> SELECT prod_id, prod_name FROM products;



C. Retrieve all columns: mysql> SELECT * FROM products; // see the first figure.

D. Retrieve different lines: mysql> select distinct prod_id FROM products; // multiple lines of the same product name are used when multiple lines of product IDs are the same, show only one row.



E restrictions: mysql> SELECT prod_name FROM products LIMIT 5; // display the first five rows



F use the full name: mysql> SELECT products. prod_id FROM lab. products;




Select statement in MYsql

Select is a query function in SQL.
For example
Select A from B

A Is What You Query
B is the target of your query

For mysql select statements in php

$ SQL = mysql_query ("select sender from message where author ER = ". $ _ SESSION ["username"]. ""); // execute the database statement while ($ re = mysql_fetch_array ($ SQL) // obtain the result. The result of the first row ends with the pointer pointing to the second row, the end of this loop the next loop gets the result of the next row until no result {echo "<a href = #> ". $ re ["sender"]. "</a> <br/>"; // output the result. $ Re ["sender"] indicates the value you have queried. For more information, see Add a connection and press Enter .}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.