<< < 22 23 24 25 26 27 28 29 30 31 32 > >>   ∑:1243  Sort:Rank

Updating Values in a Table in MySQL
How To Update Values in a Table in MySQL? If you want to update some values in one row or multiple rows in a table, you can use the UPDATE statement. The tutorial script below shows a good example: mysql&gt; UPDATE fyi_links SET counts = 999, notes = 'Good.' WHERE id = 101; Query OK, 1 row affec...
2018-01-13, 1326🔥, 0💬

Error: Subquery Returns More than 1 Row in MySQL
What Happens If the UPDATE Subquery Returns Multiple Rows in MySQL? If a subquery is used in a UPDATE statement, it must return exactly one row for each row in the update table that matches the WHERE clause. If it returns multiple rows, MySQL server will give you an error message. To test this out, ...
2018-01-08, 6955🔥, 0💬

UPDATE with Subquery Returning No Rows in MySQL
What Happens If the UPDATE Subquery Returns No Rows in MySQL? If you use a subquery to assign new values in the SET clause in an UPDATE statement, and the subquery returns no rows for an outer row, MySQL will provide a NULL value to the SET clause. The tutorial exercise below shows you a good exampl...
2018-01-08, 2094🔥, 0💬

Deleting Multiple Rows from a Table in MySQL
How To Delete Multiple Rows from a Table in MySQL? You can delete multiple rows from a table in the same way as deleting a single row, except that the WHERE clause will match multiple rows. The tutorial exercise below deletes 3 rows from the fyi_links table: mysql&gt; SELECT id, url, notes, coun...
2018-01-08, 1517🔥, 0💬

Deleting an Existing Row from a Table in MySQL
How To Delete an Existing Row from a Table in MySQL? If you want to delete an existing row from a table, you can use the DELETE statement with a WHERE clause to identify that row. Here is good sample of DELETE statements: mysql&gt; INSERT INTO fyi_links (url, id) VALUES ('www.myspace.com', 301);...
2018-01-08, 1482🔥, 0💬

Deleting All Rows in a Table in MySQL
How To Delete All Rows in a Table in MySQL? If you want to delete all rows from a table, you have two options: Use the DELETE statement with no WHERE clause. Use the TRUNCATE TABLE statement. The TRUNCATE statement is more efficient the DELETE statement. The tutorial exercise shows you a good exampl...
2018-01-08, 1390🔥, 0💬

Using Group Functions in the SELECT Clause in MySQL
How To Use Group Functions in the SELECT Clause in MySQL? If group functions are used in the SELECT clause, they will be used on the rows that meet the query selection criteria, the output of group functions will be returned as output of the query. The following select statement returns 3 values cal...
2018-01-06, 1422🔥, 0💬

Using SELECT Statements in Views in MySQL
Can SELECT Statements Be Used on Views in MySQL? Select (query) statements can be used on views in the same way as tables. The following tutorial exercise helps you creating a view and running a query statement on the view: mysql&gt; CREATE VIEW myLinks AS SELECT * FROM fyi_links WHERE url LIKE ...
2018-01-06, 1419🔥, 0💬

Count Number of Rows with SELECT Statements in MySQL
How To Use SELECT Statement to Count Number of Rows in MySQL? If you want to count the number of rows, you can use the COUNT(*) function in the SELECT clause. The following tutorial exercise shows you some good example: mysql&gt; SELECT COUNT(*) FROM fyi_links; +----------+ | COUNT(*) | +-------...
2018-01-06, 1390🔥, 0💬

What Are Group Functions in MySQL
What Are Group Functions in MySQL? Group functions are functions applied to a group of rows. Examples of group functions are: COUNT(*) - Returns the number of rows in the group. MIN(exp) - Returns the minimum value of the expression evaluated on each row of the group. MAX(exp) - Returns the maximum ...
2018-01-06, 1374🔥, 0💬

Filerting out Duplications in Returning Rows in MySQL
How To Filter Out Duplications in Returning Rows in MySQL? If there are duplications in the returning rows, and you want to remove the duplications, you can use the keyword DISTINCT in the SELECT clause. The DISTINCT applies to the combination of all data fields specified in the SELECT clause. The t...
2018-01-06, 1332🔥, 0💬

Using Table Alias Names in MySQL
How To Define and Use Table Alias Names in MySQL? When column names need to be prefixed with table names, you can define table alias name and use them to prefix column names as shown in the following select statement: mysql&gt; SELECT l.id, l.url, r.comment FROM fyi_links l INNER JOIN fyi_rates ...
2017-12-31, 1476🔥, 0💬

SELECT Statements with JOIN and Subqueries in MySQL
Where to find answers to frequently asked questions on SELECT Statements with JOIN and Subqueries in MySQL? Here is a list of frequently asked questions and their answers compiled by FYIcenter.com DBA team on SELECT Statements with JOIN and Subqueries in MySQL. Clear answers are provided with tutori...
2017-12-31, 1437🔥, 0💬

Query with an Inner Join in MySQL
How To Write a Query with an Inner Join in MySQL? If you want to query from two tables with an inner join, you can use the INNER JOIN ... ON clause in the FROM clause. The tutorial exercise below creates another testing table and returns output with an inner join from two tables: fyi_links and fyi.r...
2017-12-31, 1432🔥, 0💬

Types of Table Joins in MySQL
How To Join Two Tables in a Single Query in MySQL? Two tables can be joined together in a query in 4 ways: Inner Join: Returns only rows from both tables that satisfy the join condition. Left Outer Join: Returns rows from both tables that satisfy the join condition, and the rest of rows from the fir...
2017-12-31, 1319🔥, 0💬

Using Group Functions in the ORDER BY Clause in MySQL
Can Group Functions Be Used in the ORDER BY Clause in MySQL? If the query output is aggregated as groups, you can sort the groups by using group functions in the ORDER BY clause. The following statement returns how many links were created in each year in each tag. The group output is sorted by the c...
2017-12-31, 1295🔥, 0💬

Date and Time Intervals in MySQL
What Are Date and Time Intervals in MySQL? A date and time interval is special value to be used to increment or decrement a date or a time at a given date or time unit. A data and time interval should be expression in the format of "INTERVAL expression unit", where "unit" and "expression" should fol...
2017-12-26, 1546🔥, 0💬

Converting Dates to Character Strings in MySQL
How To Convert Dates to Character Strings in MySQL? You can convert dates to character strings using the DATE_FORMAT(date, format) function. MySQL supports the following basic formatting codes: %a Abbreviated weekday name (Sun..Sat) %b Abbreviated month name (Jan..Dec) %c Month, numeric (0..12) %D D...
2017-12-26, 1396🔥, 0💬

Converting Character Strings to Dates in MySQL
How To Convert Character Strings to Dates in MySQL? If you have a character string that represents a date, and you want to convert it into a date value, you can use the STR_TO_DATE(string, format) function. STR_TO_DATE() shares the same formatting codes with DATE_FORMAT() function. The tutorial exer...
2017-12-26, 1338🔥, 0💬

Writing Date and Time Literals in MySQL
How To Write Date and Time Literals in MySQL? MySQL offers a number of formats for you to use to enter date and time literals: ANSI standard format: "YYYY-MM-DD HH:MM:SS". Non-standard limiters. Like: "YYYY/MM/DD HH^MM^SS" or "YYYY.MM.DD HH-MM-SS". No limiters. Like: "YYYYMMDD" for a date or "HHMMSS...
2017-12-26, 1336🔥, 0💬

Entering Microseconds in SQL Statements in MySQL
How To Enter Microseconds in SQL Statements in MySQL? If you want to enter microseconds in a SQL statements, you can enter them right after the time string as a 6-digit number delimited with '.'. '0' will be padded to right if not enough digits. Here are some good examples: SELECT TIME('1997/01/31 0...
2017-12-26, 1299🔥, 0💬

Presenting a Past Time in Hours, Minutes and Seconds in MySQL
How To Present a Past Time in Hours, Minutes and Seconds in MySQL? If you want show an article was posted "n hours n minutes and n seconds ago", you can use the TIMEDIFF(NOW(), pastTime) function as shown in the following tutorial exercise: SELECT TIMEDIFF(NOW(), '2006-07-01 04:09:49') FROM DUAL; 06...
2017-12-26, 2723🔥, 0💬

Calculating the Difference between Two Time Values in MySQL
How To Calculate the Difference between Two Time Values in MySQL? If you have two time values, and you want to know the time difference between them, you can use the TIMEDIFF(time1, time2) function as shown below: SELECT TIMEDIFF(TIME('19:26:50'), TIME('09:26:50')) FROM DUAL; 10:00:00 SELECT TIMEDIF...
2017-12-26, 2402🔥, 0💬

Decrementing a Date by 1 in MySQL
How To Decrement Dates by 1 in MySQL? If you have a date, and you want to decrement it by 1 day, you can use the DATE_SUB(date, INTERVAL 1 DAY) function. You can also use the date interval subtraction operation as "date - INTERVAL 1 DAY". The tutorial exercise below gives you some good examples: SEL...
2017-12-26, 2016🔥, 0💬

<< < 22 23 24 25 26 27 28 29 30 31 32 > >>   ∑:1243  Sort:Rank