Predlošci, web design, web standardi > PHP/JS programiranje

DELETE ne radi

<< < (2/3) > >>

Dario:
Za brisanje bi ispravan query bio

--- Kod: ---DELETE FROM xlpix_acepolls_votes WHERE id IN (
SELECT id FROM (
SELECT id FROM xlpix_acepolls_votes
INNER JOIN (
SELECT MAX(ip) AS lastIp, option_id, date, MAX(id) as maxId
FROM xlpix_acepolls_votes
GROUP BY ip, DATE_FORMAT(DATE(xlpix_acepolls_votes.date), '%Y-%m-%d')
HAVING COUNT(*) > 1
) duplicate ON duplicate.lastIp = xlpix_acepolls_votes.ip
WHERE DATE_FORMAT(DATE(xlpix_acepolls_votes.date), '%Y-%m-%d') = DATE_FORMAT(DATE(duplicate.date), '%Y-%m-%d')
AND maxId > xlpix_acepolls_votes.id
AND xlpix_acepolls_votes.ip != 123
) AS x
);

--- Kraj koda ---

Dario:

--- Citat: Dario - 01. Travanj 2015, 11:26 ---Za brisanje bi ispravan query bio

--- Kod: ---DELETE FROM xlpix_acepolls_votes WHERE id IN (
SELECT id FROM (
SELECT id FROM xlpix_acepolls_votes
INNER JOIN (
SELECT MAX(ip) AS lastIp, option_id, date, MAX(id) as maxId
FROM xlpix_acepolls_votes
GROUP BY ip, DATE_FORMAT(DATE(xlpix_acepolls_votes.date), '%Y-%m-%d')
HAVING COUNT(*) > 1
) duplicate ON duplicate.lastIp = xlpix_acepolls_votes.ip
WHERE DATE_FORMAT(DATE(xlpix_acepolls_votes.date), '%Y-%m-%d') = DATE_FORMAT(DATE(duplicate.date), '%Y-%m-%d')
AND maxId > xlpix_acepolls_votes.id
AND xlpix_acepolls_votes.ip != 123
) AS x
);

--- Kraj koda ---

--- Kraj citata ---

Update/Delete nemože radit samo tako ko select ako radiš oboje na istoj tablici....

Uglavnom za update ti je isti princip samo radiš update umjesto delete...

erbi:
hm, nešto mi ne radi ..
 Parse error: syntax error, unexpected 'FROM' (T_STRING) in .....

Dario:
A neznam kaj da ti velim... ja sam testirao s SQL-om koji si mi dao i sad sam s foruma kopirao query (za svaki slucaj)...

erbi:
Onda sm ja zabrkljao ... ja sam ovo sa php ne phpmyadmin  ???

Navigacija

[0] Lista Poruka

[#] Slijedeća stranica

[*] Prethodna stranica

Idi na punu verziju