You may optionally enter a comparison operator (<, <=, >, >=, <> or =) at the beginning of each of your search values to specify how the comparison should be done.
SELECT IFNULL(MyColumn1, 1) AS MyColumnWithoutNULL;
230
MySQL
Datum, Zeit
Jahr aus Datum extrahieren
SELECT extract(year from now()) AS Year;
SELECT extract(year from '2014-01-01') AS Year;
-- 2014
231
MySQL
Datum, Zeit
Monat aus Datum extrahieren
SELECT extract(month from now()) AS Month;
SELECT extract(month from '2014-07-01') AS Month;
-- 7
232
MySQL
Datum, Zeit
Datum/Uhrzeit zusammensetzen
SELECT MAKETIME(19,53,20) AS TIME;
-- 19:53:20
SELECT MAKEDATE(2014,120) AS DATE;
-- ^^^
-- Day of Year
-- 2014-04-30
233
MySQL
Datum, Zeit
Datum/Uhrzeit berechnen
SELECT DATE_ADD(now(),INTERVAL -45 DAY) AS calculated_Day;
-- ^^^
-- Type
--
-- Available Types:
-- MICROSECOND
-- SECOND
-- MINUTE
-- HOUR
-- DAY
-- WEEK
-- MONTH
-- QUARTER
-- YEAR
-- SECOND_MICROSECOND
-- MINUTE_MICROSECOND
-- MINUTE_SECOND
-- HOUR_MICROSECOND
-- HOUR_SECOND
-- HOUR_MINUTE
-- DAY_MICROSECOND
-- DAY_SECOND
-- DAY_MINUTE
-- DAY_HOUR
-- YEAR_MONTH
235
MySQL
Datenbank
Aktuellen Datenbanknamen ausgeben
SELECT DATABASE() AS DB_Name;
236
MySQL
Strings
String nach Delimenter zerlegen
-- Not a real solution, but a workaround if you have rights to create a function
-- see: http://blog.fedecarg.com/2009/02/22/mysql-split-string-function/
-- same problem with MSSQL.
CREATE FUNCTION SPLIT_STR(
StringToBeSplitted VARCHAR(255),
delimiter VARCHAR(12),
position INT
)
RETURNS VARCHAR(255)
RETURN REPLACE(SUBSTRING(SUBSTRING_INDEX(StringToBeSplitted, delimiter, position),
LENGTH(SUBSTRING_INDEX(StringToBeSplitted, delimiter, position -1)) + 1),
delimiter, '');
SELECT SPLIT_STR(string, delimiter, position);
237
MySQL
Strings
String nach einem Teilstring durchsuchen
SELECT
myString
,locate('#',myString,5) AS findPosition -- Result is: 8
,left(myString,locate('#',myString,2)-1) AS ExtractedString -- Result is: abc
,left(myString,locate('#',myString,5)) AS ExtractedString -- Result is: abc#def#
FROM
(
SELECT
'abc#def#ghj' AS myString
) dummyString
7
Mumps
Datum, Zeit
Aktuelles Datum/Uhrzeit
; The first integer is the number of days since December 31, 1840, where day 1 is January 1, 1841. The second integer is the number of seconds since midnight of the current day
Set h=$horolog
S h=$H
W !,h ; gibt aus 61793,34937 was dem Datum 2010-03-08 und der Uhrzeit 09:42:17 entspricht
11
Mumps
Datenbank
Lesen Datensatzes
; In M werden Tabellen Globals genannt
S id=1
W !,^TABLE(id)
S street="Hollywood Drive"
S city="Los Angeles"
W !,^PERSONS(street,city)
S temp=^GLOBAL(0,"test","temp1")