Using initial query to determine column array info?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
robster
Forum Contributor
Posts: 360
Joined: Wed Jul 16, 2003 8:28 am
Location: Sunshine Coast, Australia

Using initial query to determine column array info?

Post by robster »

Hi all,

I have a table with data similar to this for example:

Code: Select all

1
1
2
1
2
2
3
4
6
5
5
1
and I'd like to create an array with the following info:

Code: Select all

1, 2, 3, 4, 5, 6
(order not essential)

The question then, is: Using MySQL 4.x, Is there a way to have the initial query return the results I need, without having to parse through the table and manually push the data into an array?

My SQL is still quite beginner level.

Any advice would be really appreciated! :)

Rob
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

Look into the DISTINCT keyword in SQL.
(#10850)
User avatar
robster
Forum Contributor
Posts: 360
Joined: Wed Jul 16, 2003 8:28 am
Location: Sunshine Coast, Australia

Post by robster »

Thank you so much, looks like it's better than group by for some things:
http://www.liamdelahunty.com/tips/mysql ... oup_by.php

Muchly appreciated!
Post Reply