Autor | Zpráva | ||
---|---|---|---|
unlucky Profil |
#1 · Zasláno: 28. 12. 2011, 21:16:54 · Upravil/a: Moderátor (editace znemožněna) 19. 1. 2012, 15:45:20
Podival jsem se nahoru na FAQ a query mi nejak nefunguje :P
articles - id, article_id categories - id hlasi mi unknown column k.id select c2.* from articles c2 join (select k.id, (select id from articles c where c.article_category= k.id order by id desc limit 4, 1) hranice from categories k) h on c2.article_category= k.id and c2.id>= ifnull(h.hranice, c2.article_category) |
||
DJ Miky Profil |
#2 · Zasláno: 28. 12. 2011, 21:21:51
Při zběžném pohledu by na předposledním řádku asi mělo být:
... on c2.article_category= h.id |
||
unlucky Profil |
#3 · Zasláno: 28. 12. 2011, 21:48:12 · Upravil/a: unlucky
jj, dekuji, tam byl ten problem
A kdybych chtel vypsat treba z kategorii 17,20,21 jak to bude? select c2.* from articles c2 join (select k.id, (select id from articles c where c.article_category= k.id order by id desc limit 4, 1) hranice from categories k where k.id in (17,20,21) ) h on c2.article_category= h.id and c2.id>= ifnull(h.hranice, c2.article_category) Lze nejdrive vypsat treba 20 pak 17 a 21? |
||
Mastodont Profil |
#4 · Zasláno: 28. 12. 2011, 22:08:45
Zkus
ORDER BY FIELD(k.id, 20, 17, 21) |
||
unlucky Profil |
#5 · Zasláno: 28. 12. 2011, 23:20:27
mam
select c2.* from articles c2 join (select k.id, (select id from articles c where c.article_category= k.id order by id desc limit 4,1) hranice from categories k where k.id in(20,21,17,27) ORDER BY FIELD(k.id, 21, 20,17,27) ) h on c2.article_category= h.id and c2.id>= ifnull(h.hranice, c2.article_category) |
||
Kajman Profil |
#6 · Zasláno: 29. 12. 2011, 08:50:26 · Upravil/a: Kajman
unlucky:
„FAQ a query mi nejak nefunguje“ Opraveno i tam. „neserazuje to“ Order by nedávejte do poddotazu, tam to neovlivní. Zkuste select c2.* from articles c2 join (select k.id, (select id from articles c where c.article_category = k.id order by id desc limit 4, 1) hranice from categories k where k.id in (20, 21, 17, 27)) h on c2.article_category = h.id and c2.id >= ifnull(h.hranice, c2.article_category) ORDER BY FIELD(h.id, 21, 20, 17, 27), c2.id desc |
||
unlucky Profil |
#7 · Zasláno: 29. 12. 2011, 18:59:30 · Upravil/a: unlucky
dekuji, je to perfektni
a v title chybi "ch" :( |
||
Časová prodleva: 12 let
|
0