Jump to content
php.lv forumi

order by no visas datubaazes


tikkai maacos

Recommended Posts

tabulas rinas

row1

row2

row3

row4

row5

time

 

man ir taaads kuerijs!

 

$result = mysql_query("SELECT * FROM table_1 where row1='1' AND row2='"1."' and row3='1' order by time desc ")

 

viss ir ok.. bet dati tiek izvadiiti peec pieprasiijuma un dilstoshas laika seciibas starp atlasitajiem ieraxtiem! bet vai ir iespeejams izveidot seciibu taa lai laiku njemtu no visiem pieraxtiem!

 

Paldies jau ieprieksh!

Link to comment
Share on other sites

kaa tu to domaa, laiku njem notu no visiem pierakstiem? tavs select teikums jau arii njem laiku no visiem pierakstiem kas atbilst where nosaciijumam.

 

Ja biji domaajis, ka, piem., tev ir shaada te tabula:

 

col1 | col2 | time

---------------------

aaa1 | aaa2 | 100

bbb1 | bbb2 | 101

xxx1 | xxx2 | 102

ddd1 | ddd2 | 103

 

Un uztaisi

SELECT * FROM `tabula` WHERE `col1`='aaa1' AND `col2`='bbb2' ORDER BY `time` DESC;

 

tiks atlasiits:

 

col1 | col2 | time

---------------------

bbb1 | bbb2 | 101

aaa1 | aaa2 | 100

 

Ar to tev vai tad nepietiek?

 

p.s. ja nu kas, tad paskaidro bisk siikaak, jo man pa nakti neaiziet tik aatri ko iisti nevari sakodeet ;) :D

Link to comment
Share on other sites

news_id | cat_id | com_id | title | active | time

--------------------------------------------------------

1 | 1 | 1 | title1 | 1 | 10:01

2 | 1 | 1 | c_title1 | 0 | 10:13

3 | 2 | 1 | title2 | 1 | 10:08

4 | 2 | 1 | c_title2 | 0 | 10:10

5 | 2 | 1 | c_title2 | 0 | 10:12

 

 SELECT * FROM tabula WHERE com_id='1' AND cat_id=1 AND active='1' order by 'time'  DESC

 

UN LAI IZVADA

 

title | last coment @ 10:13

title2 | last coment @ 10:12

 

 

ceru ka saprataat...

Edited by tikkai maacos
Link to comment
Share on other sites

$result = mysql_query("SELECT * FROM `news` ORDER BY `datestamp` DESC LIMIT 0, 10");

while($news = mysql_fetch_array($result))
{
print $news['title']." | ".$news['comments']." @ ".$news['datestamp']."";
}

 

 

// LIMIT 10 ( cik izvadit zinjas kopa ... )

Link to comment
Share on other sites

$result = mysql_query("SELECT * FROM `news` ORDER BY `datestamp` DESC LIMIT 0, 10");

while($news = mysql_fetch_array($result))
{
print $news['title']." | ".$news['comments']." @ ".$news['datestamp']."";
}

 

 

// LIMIT 10 ( cik izvadit zinjas kopa ... )

 

nu jaa... to es saprotu... bet vajag lai sortee peec visiem ieraxtiem time kur news_id = 1

 

tas vareetu izskatiities shaadi

 

$result = mysql_query("SELECT * FROM `news` ORDER BY (SELECT time FROM `news` where news_id=`1`") DECS;

 

vai kaut kaa taa.. :)

Link to comment
Share on other sites

×
×
  • Create New...