How to print one row only ?

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Erick020
New php-forum User
New php-forum User
Posts: 13
Joined: Thu Dec 26, 2002 6:20 am

How to print one row only ?

Postby Erick020 » Mon Dec 30, 2002 4:06 am

I've got in a table several entries (like dates) and of course several rows with the same date. I'd like to print only one row of each date on a page. With something like a 'like statement'
I get my result but if I have 10 times the same date I'll print 10 lines on my page instead of ONE only.

Is there a way to do that ? and how? I'll appreciate a clear exemple.

Thanks a lot for your help.
Erick.

User avatar
Oleg Butuzov
Last Samuray
Last Samuray
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby Oleg Butuzov » Mon Dec 30, 2002 11:49 am

Code: Select all

SELECT * FROM `table` LIMIT 0, 1

Erick020
New php-forum User
New php-forum User
Posts: 13
Joined: Thu Dec 26, 2002 6:20 am

Postby Erick020 » Thu Jan 02, 2003 4:32 am

Pejone wrote:

Code: Select all

SELECT * FROM `table` LIMIT 0, 1


Thanks for your answer.

It works but this is not the result I wanted because how I explain my problem was wrong.
I actualy have several rows with the same date AND different dates.
Exemple: 29 dec.2002
29 dec.2002
29 dec.2002
30 dec.2002
30 dec.2002
31 dec.2002
31 dec.2002 etc...

What I'd like to print is: 29 dec.2002
30 dec.2002
31 dec.2002

I hope it's clearer now.
One more thing: The querry I had has changed and the (LIMIT statement doesn't work any longer - I think)
The new querry I have is:

$q = "SELECT
F_Num, Date, User_ID, User_Country
FROM
tableA, tableB
WHERE
tableA.User_ID = tableB.User_ID
ORDER by Date desc
";

Thank to all for your help, and Happy new year
Erick

jemy
New php-forum User
New php-forum User
Posts: 6
Joined: Thu Jan 02, 2003 5:27 am
Location: Munich / Germany

Postby jemy » Thu Jan 02, 2003 6:39 am

Hi,

is that what you where looking for?

$q = "SELECT
F_Num, Date, User_ID, User_Country
FROM
tableA, tableB
WHERE
tableA.User_ID = tableB.User_ID
GROUP by Date <---------- !!!!!!!
ORDER by Date desc
";

Erick020
New php-forum User
New php-forum User
Posts: 13
Joined: Thu Dec 26, 2002 6:20 am

Postby Erick020 » Thu Jan 02, 2003 7:00 am

jemy wrote:Hi,

is that what you where looking for?

$q = "SELECT
F_Num, Date, User_ID, User_Country
FROM
tableA, tableB
WHERE
tableA.User_ID = tableB.User_ID
GROUP by Date <---------- !!!!!!!
ORDER by Date desc
";


Thanks a lot.....
I completely forgot that one !!! 'GROUP by Date' !
Erick


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 1 guest

cron