Maccess - Help

This is just a brief help that assumes at least some Maccess skills.


Joining of Tables

This example shows joining of tables Invoice and Customer based on customer column that is contained in both of the tables (to be unambiguous, it is necessary to use exact columns names in form of Tabel.Column, i.e. Invoice.customer and Customer.customer).


Comparative Operators

In Maccess comparative operators are used in Condition boxes as well as in Join condition boxes.

< > = <> <= >=

This example shows limitation on lines - the name column is John.

This example shows limitation on lines - the price column is greater than or equal to 1000.

IN (str,str,..) a NOT IN (str,str,..)

This example shows limitation on lines - the name column is John or Peter.

LIKE pat a NOT LIKE pat

The comparative operator LIKE uses two special symbols:

This example shows limitation on lines - the name column begins with P symbol (case insensitive).

REGEXP pat a NOT REGEXP pat

For more information please click here.

IS NULL a IS NOT NULL

Test for NULL value.


Logical Operators

In Maccess logical operators are used in Condition boxes as well as in Join condition boxes.

NOT - negation

OR - logical or

AND - logical and

This example shows limitation on lines - the price column is greater than or equal to 1000 and at the same time it is lower than 2000.


Arithmetical Operations

In Maccess arithmetical operations may be used in Column boxes as well as in Condition boxes and Join condition boxes.

+ - addition

- - subtraction

* - multiplication

/ - division

This example shows limitation on lines - product of price column and quantity column is greater than 1000/1.22.


Grouping Function of Brackets ( )

In Maccess brackets are of grouping function - they may be used in Column boxes as well as Condition boxes and in Join condition boxes.


Query Variables

In Maccess when creating a query especially in Condition column if you want to give a condition, you do not put an actual value but a variable. When running a query Maccess asks about the appropriate value. Each such a variable must be closed in square brackets and its name must end with colon.

This example shows form generating asking about a simple variable.

This example shows form generating asking about a variable given thus that select menu generates. As value there will be put instead of variable value of 199901 or 199902.

There are other possibilities of query variables - behind colon is put SQL command - see the following two examples.


Functions

In Maccess functions may be used in Column boxes, Condition boxes as well as in Join condition boxes.


Mathematical Functions

ABS(N) - returns the absolute value of N

SIGN(N) - returns the sign of the argument N

SIGN(-32) -> -1; SIGN(0) -> 0; SIGN(32) -> 1

MOD(N1,N2) - returns the remainder of N1 divided by N2

POWER(N,X) - returns the value of N raised to the power of X

SQRT(N) - returns the non-negative square root of N

FLOOR(N) - returns the largest integer value not greater than N

CEILING(N) - returns the smallest integer value not less than N

ROUND(N[,D]) - returns the argument N, rounded to a number with D decimals

TRUNCATE(N,D) - returns the number N, truncated to D decimals

LEAST(N1,N2,...) - with two or more arguments, returns the smallest (minimum-valued) argument

GREATEST(N1,N2,...) - returns the largest (maximum-valued) argument

INTERVAL(N,N1,N2,N3,...) - returns 0 if N<N1, 1 if N<N2 and so on

Others mathematical functions: EXP(N), LOG(N), LOG10(N), PI(), COS(N), SIN(N), TAN(N), ACOS(N), ASIN(N), ATAN(N), ATAN2(N1,N2), COT(N), DEGREES(N), RADIANS(N), RAND([N])


String Functions

CONCAT(str1,str2,...) - returns the string that results from concatenating the arguments

CONCAT('Hi',' ','John!') -> Hi John!

CONCAT_WS(separator, str1, str2,...) - CONCAT_WS() stands for CONCAT with separator

LENGTH(str) - returns the length of the string str

LENGTH('Hi John!') -> 8

LOCATE(substr,str[,pos]) - returns the position of the first occurrence of substring substr in string str, starting at position pos

LOCATE('John','Hi John!') -> 4

LEFT(str,len) - returns the leftmost len characters from the string str

RIGHT(str,len) - returns the rightmost len characters from the string str

SUBSTRING(str,pos[,len]) - returns a substring len characters long from string str, starting at position pos

SUBSTRING('Hi John!',4,5) -> John!

SUBSTRING_INDEX(str,delim,count)

SUBSTRING_INDEX('www.mysql.com', '.', 2) -> 'www.mysql'

SUBSTRING_INDEX('www.mysql.com', '.', -2) -> 'mysql.com'

INSERT(str,pos,len,newstr) - returns the string str, with the substring beginning at position pos and len characters long replaced by the string newstr

INSERT('Hi !',4,0,'John') -> Hi John!

REPLACE(str,from_str,to_str) - returns the string str with all all occurrences of the string from_str replaced by the string to_str

REPLACE('Hi John!','o','O') -> Hi JOhn!

LPAD(str,len,padstr) - returns the string str, left-padded with the string padstr until str is len characters long

LPAD('7',3,'0') -> 007

RPAD(str,len,padstr) - returns the string str, right-padded with the string padstr until str is len characters long

LTRIM(str) - returns the string str with leading space characters removed

RTRIM(str) - returns the string str with trailing space characters removed

TRIM([[BOTH | LEADING | TRAILING] [remstr] FROM] str) - returns the string str with all remstr prefixes and/or suffixes removed, if none of the specifiers BOTH, LEADING or TRAILING are given, BOTH is assumed

TRIM('   Hi  ') -> 'Hi'

TRIM(LEADING '0' FROM '0070') -> '70'

SPACE(N) - returns a string consisting of N space characters

REPEAT(str,count) - returns a string consisting of the string str repeated count times

REVERSE(str) - returns the string str with the order of the characters reversed

REVERSE('abcd') -> dcba

ELT(N,str1,str2,str3,...) - returns str1 if N = 1, str2 if N = 2, and so on

FIELD(str,str1,str2,str3,...) - returns the index of str in the str1, str2, str3, ... list

FIELD('ej', 'Hej', 'ej', 'Heja', 'hej', 'foo') -> 2

FIND_IN_SET(str,strlist)

FIND_IN_SET('b','a,b,c,d') -> 2

LCASE(str) - returns the string str with all characters changed to lowercase

LCASE('Hi John!') -> 'hi john!'

UCASE(str) - returns the string str with all characters changed to uppercase

Others string functions: ASCII(str), ORD(str), CONV(N,from_base,to_base), BIN(N), OCT(N), HEX(N), CHAR(N,...), INSTR(str,substr), SOUNDEX(str)


Date and Time Functions

DAYOFWEEK(date) - returns the weekday index for date

1=Sunday, 2=Monday, ...

WEEKDAY(date) - returns the weekday index for date

0=Monday, 1=Tuesday, ...

DAYOFMONTH(date) - returns the day of the month for date

DAYOFYEAR(date) - returns the day of the year for date

MONTH(date) - returns the month for date

MONTH('1999-05-25') -> 5

QUARTER(date) - returns the quarter of the year for date

QUARTER('1998-04-01') -> 2

WEEK(date[,1]) - With a single argument, returns the week for date, in the range 0 to 53 (yes, there may be the beginnings of a week 53), for locations where Sunday is the first day of the week. The two-argument form of WEEK() allows you to specify whether the week starts on Sunday or Monday. The week starts on Sunday if the second argument is 0, on Monday if the second argument is 1

YEAR(date) - returns the year for date

YEAR('1998-02-03') -> 1998

YEARWEEK(date[,1]) - returns year and week for a date (note that the year may be different from the year in the date argument for the first and the last week of the year)

YEARWEEK('1987-01-01') -> 198653

PERIOD_ADD(P,N) - adds N months to period P

PERIOD_ADD('199908',5) -> 200001

PERIOD_DIFF(P1,P2) - returns the number of months between periods P1 and P2

PERIOD_DIFF(199905,199901) -> 4

TO_DAYS(date) - given a date date, returns a daynumber (the number of days since year 00

FROM_DAYS(N) - given a daynumber N, returns a DATE value

CURDATE() - returns today's date

Others date and time functions: DAYNAME(date), MONTHNAME(date), HOUR(time), MINUTE(time), SECOND(time), DATE_ADD(date,INTERVAL expr type), DATE_SUB(date,INTERVAL expr type), DATE_FORMAT(date,format), TIME_FORMAT(time,format), CURTIME(), NOW(), SEC_TO_TIME(seconds), TIME_TO_SEC(time), UNIX_TIMESTAMP([date]), FROM_UNIXTIME(unix_timestamp[,format]), ...


Various Functions

IF(expr1,expr2,expr3) - if expr1 is TRUE (expr1<>0 and expr1<>NULL) then IF() returns expr2, else it returns expr3

IF(1>2,2,3) -> 3

FORMAT(N,D) - formats the number X to a format like '#,###,###.##', rounded to D decimals

ISNULL(X) - if expr is NULL, ISNULL() returns 1, otherwise it returns 0

Some columns in tables may be NULL, please pay attention to the fact that NULL is not the same as 0 or ´´ (empty string). When calculating a return value may be NULL - e.g.: 1/0=NULL.