Danh mục

Mysql your visual blueprint for creating open source databases- P9

Số trang: 20      Loại file: pdf      Dung lượng: 576.68 KB      Lượt xem: 7      Lượt tải: 0    
Jamona

Xem trước 2 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

Mysql your visual blueprint for creating open source databases- P9:The show tables command displays a list of tables available in the currently selected database. You can use this command when you are unsure of the exact name of a table within the database.
Nội dung trích xuất từ tài liệu:
Mysql your visual blueprint for creating open source databases- P9 USING MYSQL FUNCTIONS 7 MySQL also includes functions that allow you to search a string for a particular substring. The first of these, LOCATE, searches a text value for a string you specify. If the string is found within the larger string, it returns a number indicating the character position where it starts. If the string is not found, LOCATE returns zero. The following query searches the values of the quote column in the quotes table for the string every and displays the results: Example: SELECT LOCATE(every, quote) FROM quotes; The LOCATE function also accepts a third optional parameter. If you specify a number after the two strings, MySQL will only search for the substring starting with the character index you specify. This is useful when you want to find the second or third occurrence of a string. MySQL also supports the INSTR function for compatibility with other database systems. This function is similar to LOCATE, but the parameters are in the opposite order: you first specify the larger string, and then the substring to search for. Unlike LOCATE, INSTR does not support a starting position for the search.› Type SELECT author, s This displays the author Á Type SELECT author, s This displays the authorRIGHT(quote, 10) and press column and the last ten MID(quote, 5, 10) and press column and ten characters ofEnter. characters of the quote Enter. the quote column, starting at column for each row. the fifth character.ˇ Type FROM quotes; and ‡ Type FROM quotes; andpress Enter. press Enter. 147 MySQLUNDERSTANDING DATE ANDTIME FUNCTIONS MySQL also includes a number of functions that allow youM ySQL allows you to store a date or date/time combination in several column types, including to work with dates and times and convert them into DATE, TIME, DATETIME, and TIMESTAMP. different formats.GET THE CURRENT DATE If you need to know the current date within a MySQL The CURRENT_DATE function returns the current date query, you can use the NOW function. This function only. This function can be abbreviated CURDATE. The returns the current date and time. If you use this CURRENT_TIME and CURTIME functions are similar but function as a string value, it will return a string with return only the hours, minutes, and seconds values for the year, month, date, hour, minute, and second with the current time. punctuation in between. If you use the result as a numeric value, it will contain no punctuation. The NOW function does not require any parameters. The SYSDATE and CURRENT_TIMESTAMP functions are synonyms for NOW.WORK WITH DATE COMPONENTS MySQL includes a variety of FUNCTION DESCRIPTION functions for extracting components, such as the day of the DAYOFWEEK Numeric day of week (1-7 for Sunday-Saturday) week or the week of the year, from WEEKDAY Numeric day of week (0-6 for Monday-Sunday) a date value. The following table describes these functions. DAYNAME Name of day of week The HOUR, MINUTE, and SECOND DAYOFMONTH Day of month (1-31) functions work only with values DAYOFYEAR Day of year (1-366) that include a time, such as MONTH Numeric month (1-12) TIMESTAMP or TIME columns. The other functions work only with MONTHNAME Name of month values that include a date. QUARTER Numeric quarter ...

Tài liệu được xem nhiều: