Przykład użycia funkcji GROUP_CONCAT

SELECT GROUP_CONCAT(kto ORDER BY kto ASC SEPARATOR ', ') FROM raport_ludzie_spotkania

Złączenie rekordów wątku do jednego stringa, wycinanie 80 znaków stringa:

SELECT t.ticket_id, t.created,
SUBSTRING(last_notes_title, 1, (80 + LOCATE(' ', last_notes_title, 80))) AS last_notes_title,
SUBSTRING(last_notes_body, 1, (80 + LOCATE(' ', last_notes_body, 80))) AS last_notes_body
FROM (
SELECT ticket_id, created,
GROUP_CONCAT(title ORDER BY created DESC SEPARATOR '|') AS last_notes_title,
GROUP_CONCAT(body ORDER BY created DESC SEPARATOR '|') AS last_notes_body
FROM ost_ticket_thread WHERE ticket_id IN (1,2,3,4,5) GROUP BY ticket_id
) AS t

Odczyt atrybutu title

function get_title(obj) {
 var title = ”;
 if(obj.getAttribute(‚title’)) {
  title = obj.getAttribute(‚title’);
  title = title.substring(5);
 }
 return {title:title,value:title};
}

Zwiększenie lub zmieniszenie daty o 1 dzień

function next_day(f, step) {

var data = f.value;
var tab = data.split("-");

var year = tab[0];
var month = tab[1];
var day = tab[2];
var date = new Date(year, month-1, day);

var now = date;
now.setDate(now.getDate() + step);
var year=now.getFullYear();
var month=now.getMonth()+1;
var day=now.getDate();

month = "0" + month;
month = month.substring(month.length-2, month.length);

day = "0" + day;
day = day.substring(day.length-2, day.length);

return year+"-"+month+"-"+day;
}

uruchomienie

var f2 = forma.elements["departure_date"];
var f1 = forma.elements["arrival_date"];

f1.value = next_day(f1, 1);
f2.value = next_day(f2, 1);

f1.value = next_day(f1, -1);
f2.value = next_day(f2, -1);

Wykorzystanie LOCATE i REGEXP

SELECT LOCATE( ' ', address ) pos, address, SUBSTRING_INDEX(address, ' ', -1), address REGEXP '[:digit:]' FROM hotele
SELECT LOCATE( ' ', address ) pos, address, SUBSTRING_INDEX( address, ' ', -1 ) , address REGEXP '[[:digit:]]' FROM hotele
SELECT LOCATE( ' ', address ) pos, address, SUBSTRING_INDEX( address, ' ', -1 ) , address REGEXP '[[:digit:]]' FROM hotele WHERE SUBSTRING_INDEX( address, ' ', -1 ) REGEXP '[[:digit:]]'
update hotele set nr_domu = SUBSTRING_INDEX( address, ' ', -1 ) WHERE SUBSTRING_INDEX( address, ' ', -1 ) REGEXP '[[:digit:]]'
SELECT LOCATE( ' ', REVERSE(address) ) pos, address, trim(SUBSTRING( address, 1, LENGTH(address) - LOCATE( ' ', REVERSE(address) ))) FROM hotele WHERE SUBSTRING_INDEX( address, ' ', -1 ) REGEXP '[[:digit:]]'
update hotele set ulica = trim(SUBSTRING( address, 1, LENGTH(address) - LOCATE( ' ', REVERSE(address) ))) WHERE SUBSTRING_INDEX( address, ' ', -1 ) REGEXP '[[:digit:]]'