![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Confirmed User
Join Date: Jun 2002
Location: france
Posts: 996
|
MySql simple question
let's say that i have a table with 3 collumns and 10 rows..
i want to select all the rows with 1 collumn different (no mether if collumns 2 and 3 are different or not) how do i do that? with SELECT DISTINCT there are selected only rows wuth all 3 collomns different or how? thx |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
Confirmed User
Join Date: Sep 2003
Location: Las Vegas, NV
Posts: 350
|
just download the mysql bible offa kazaa, i'm sure its in there if it exists, or mysql.com has extensive documentation.
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
PornSiteDomains.com
Industry Role:
Join Date: Oct 2002
Location: US
Posts: 1,265
|
Something like the following should work:
SELECT DISTINCT(YOURCOLUMNNAME) FROM YOURTABLENAME |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 | |
Confirmed User
Join Date: May 2003
Posts: 1,792
|
Quote:
__________________
ICQ: 282814268 |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 | |
Confirmed User
Join Date: Jun 2002
Location: france
Posts: 996
|
Quote:
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource ******* any others ideeas? |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 |
Confirmed User
Join Date: Apr 2003
Location: Loveland, CO
Posts: 5,526
|
If you're getting an "not a valid mysql resource" then it looks like the connection to the DB is bad. A bad query would return another error code.
So i'd say that JCK's response would be fine: select distinct() from table should work.
__________________
Your post count means nothing. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 | |
Confirmed User
Join Date: Jun 2002
Location: france
Posts: 996
|
Quote:
i want retrire all the row with all thre informations (date, name, location) but name shuld not apeare 2 times.. if i use SELECT DISTINCT * FROM TABLE if there are 2 rows with same name but with different dates then they will be displayed if i use SELECT DISTINCT name, location FROM TABLE then i will not be able to use the informations about date.. can somebody help me with the right sintax, pls? ![]() |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#8 |
Confirmed User
Join Date: Apr 2003
Location: Loveland, CO
Posts: 5,526
|
So
SELECT DISTINCT(name), date, location FROM tableName doesn't work. How about fuckin' around with Group BY clauses (mind i didn't check my syntax cuz i'm lazy) SELECT name, date, location FROM tableName GROUP BY name, date, location and see what your result set looks like.
__________________
Your post count means nothing. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#9 | |
Confirmed User
Join Date: Jun 2002
Location: france
Posts: 996
|
Quote:
so, select distinct(colomn1) from table will display just the colomn1 informations, not all 3 colomns ![]() i wnt display all the 3 colomns where one colomn is distinct |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#10 |
Confirmed User
Join Date: Jul 2002
Location: A warm place.
Posts: 634
|
Install PostgreSQL and use the real command that's designed for this kinda stuff: MINUS
SELECT product_id FROM inventories MINUS SELECT product_id FROM order_items;
__________________
I couldn't possibly know what I'm talking about, I'm completely, absolutely and definitively out of my fucking mind. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#11 | |
Confirmed User
Join Date: Jun 2002
Location: france
Posts: 996
|
Quote:
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#12 |
Confirmed User
Join Date: Mar 2002
Location: how'd I get here?
Posts: 264
|
I think you're looking for,
select distinct(name),date,location FROM tableName GROUP BY name; You only want the group by on the name, since that's the one that you're making distinct. mysql> create table test ( name char(20), date char(20), location char(20) ); Query OK, 0 rows affected (0.16 sec) mysql> show tables; +----------------+ | Tables_in_test | +----------------+ | test | +----------------+ 1 row in set (0.00 sec) mysql> show fields from test; +----------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------+----------+------+-----+---------+-------+ | name | char(20) | YES | | NULL | | | date | char(20) | YES | | NULL | | | location | char(20) | YES | | NULL | | +----------+----------+------+-----+---------+-------+ 3 rows in set (0.00 sec) mysql> insert into test values ( 'buran', '12345', 'orlando' ); Query OK, 1 row affected (0.00 sec) mysql> insert into test values ( 'buran', '67890', 'indiana' ); Query OK, 1 row affected (0.00 sec) mysql> insert into test values ( 'twinkley', 'abc123', 'michigan' ); Query OK, 1 row affected (0.00 sec) mysql> select distinct(name),date,location from test group by name; +----------+--------+----------+ | name | date | location | +----------+--------+----------+ | buran | 12345 | orlando | | twinkley | abc123 | michigan | +----------+--------+----------+ 2 rows in set (0.00 sec) mysql>
__________________
[this signature intentionally left blank] |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#13 | |
Confirmed User
Join Date: Aug 2003
Posts: 146
|
Quote:
Lets say that you have these rows: April 1, Jane, Toronto April 3, Jane, Edmonton April 5, Jane, Calgary April 7, Bob, New York -- okay.. obviously, you want to get back "April 7, bob, New York" but how do you want the database to choose which other row you get back? You can make it choose at random, but keep in mind, the data you get back will be random too.
__________________
My Favorite Game |
|
![]() |
![]() ![]() ![]() ![]() ![]() |