Collections:
Select Rows with WHERE Clause in MySQL
How To Select Some Rows from a Table in MySQL?
✍: FYIcenter.com
If you don't want select all rows from a table, you can specify a WHERE clause to tell the query to return only the rows that meets the condition defined in the WHERE clause. The WHERE clause condition is a normal Boolean expression. If any data from table needs to be used in the Boolean expression, column names should be used to represent the table data.
The first select statement below only returns rows that have url names containing the letter "a". The second select statement returns no rows, because the WHERE clause results FALSE for all rows in the table.
mysql> SELECT * FROM fyi_links WHERE url LIKE '%a%'; +-----+-------------------+-------+--------+--------------- | id | url | notes | counts | created +-----+-------------------+-------+--------+--------------- | 102 | dba.fyicenter.com | NULL | 0 | 2006-07-01 12: | 103 | sqa.fyicenter.com | NULL | NULL | 2006-07-01 12: +-----+-------------------+-------+--------+--------------- 2 rows in set (0.00 sec) mysql> SELECT * FROM fyi_links WHERE FALSE; Empty set (0.00 sec)
⇒ Adding More Data to the Test Table in MySQL
⇐ Selecting Columns in a Query in MySQL
2017-11-02, 1512🔥, 0💬
Popular Posts:
How to change the data type of an existing column with "ALTER TABLE" statements in SQL Server? Somet...
How To Locate and Take Substrings with CHARINDEX() and SUBSTRING() Functions in SQL Server Transact-...
How To Generate CREATE VIEW Script on an Existing View in SQL Server? If you want to know how an exi...
What is sqlservr.exe - Process - SQL Server (SQLEX?PRESS) in SQL Server? Process sqlservr.exe is the...
How To Divide Query Output into Multiple Groups with the GROUP BY Clause in SQL Server? Sometimes, y...