Okay, so I do this and all I end up with is

+-----+-----------+-------------+-----------+
| id  | lname     | fname       | engagedto |
+-----+-----------+-------------+-----------+
| 131 | Hallows   | Samuel      | 131       |
| 273 | Simmons   | Maria       | 273       |
| 221 | Papa      | Sharla      | 221       |
|  18 | Biehl     | Ruth        | 18        |
| 302 | Vance     | Alicia      | 302       |
| 123 | Goettl    | Christopher | 123       |
|  78 | Ellsworth | Morgan      | 78        |
| 204 | Millet    | David       | 204       |
+-----+-----------+-------------+-----------+
8 rows in set (0.00 sec)

The returning query doesn't seem very helpful.
I guess what I want is mysql to return the results with each person they are
engaged to in order.

I added the p1.id and p1.engagedto fields.

mysql> select p1.id, p1.lname, p1.fname, p1.engagedto, p2.engagedto from
members p1, members p2 where p1.id = p2.engagedto;
+-----+-----------+-------------+-----------+-----------+
| id  | lname     | fname       | engagedto | engagedto |
+-----+-----------+-------------+-----------+-----------+
| 131 | Hallows   | Samuel      | 18        | 131       |
| 273 | Simmons   | Maria       | 78        | 273       |
| 221 | Papa      | Sharla      | 123       | 221       |
|  18 | Biehl     | Ruth        | 131       | 18        |
| 302 | Vance     | Alicia      | 204       | 302       |
| 123 | Goettl    | Christopher | 221       | 123       |
|  78 | Ellsworth | Morgan      | 273       | 78        |
| 204 | Millet    | David       | 302       | 204       |
+-----+-----------+-------------+-----------+-----------+
8 rows in set (0.01 sec)

This at least shows me the info I had in my original table.  If I looked at
it I could see that id# 131 should match up with id# 18 and such.  I guess
I'm looking for a query that will match these to up either in the same row
or one after another.

Any help is SOOO appreciated!

Dean

----- Original Message -----
From: "Roger Karnouk" <[EMAIL PROTECTED]>
To: "Dean Householder" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Tuesday, February 19, 2002 12:17 PM
Subject: RE: basic query question


you will have to join the table with itself
and reference it as if it is two tables.
this might be slow however so you might want to make some
specific indexes to speed it up.

This Query will return all the people who are engaged
and a picture of their fiancé:

select p1.lname, p1.fname, p1.pic, p2.pic
from people p1, people p2
where p1.id = p2.engagedto;

this query will return people whether they are engaged or not:
select p1.lname, p1.fname, p1.pic, p2.pic
from people p1 left join people p2 on (p1.id = p2.engagedto);

-----Original Message-----
From: Dean Householder [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 19, 2002 12:22 PM
To: [EMAIL PROTECTED]
Subject: basic query question


I'm fairly new to MySQL, so if anyone could help me I'd really appreciate
it!

What I'm trying to do is join two pictures in a database to each other.  My
database holds info about people with variables:

id, lname, fname, engagedto, pic

The engagedto field contains the id of the person they are engaged to.  I'm
trying to print the people that are engaged to each other next to each
other.  I've played with the join command and a little with group but don't
really understand how these work...  If anyone could point me in the right
direction regarding how to query the database to return these records
connected to each other, I would really appreciate it!

Thanks so much

Dean


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to